public function findFirstOccurenceOfFile(string $fileName)
    {
        if (!$this->isDir() || !$this->exists()) {
            return null;
        }

        foreach ($this->scanDir() as $file) {
            if ($file->getFileName() === $fileName) {
                return $file;
            }

            if ($file->isDir()) {
                $result = $file->findFirstOccurenceOfFile($fileName);
                if ($result !== null) {
                    return $result;
                }
            }
        }
        return null;
    }
public function findFirstOccurenceOfFile(string $fileName)
    {
        if (!$this->isDir() || !$this->exists()) {
            return null;
        }

        foreach ($this->scanDir() as $file) {
            if ($file->getFileName() === $fileName) {
                return $file;
            }

            if ($file->isDir()) {
                $result = $file->findFirstOccurenceOfFile($fileName);
                if ($result !== null) {
                    return $result;
                }
            }
        }
        return null;
    }
public function findFirstOccurenceOfFile ( string $ fileName ) { if ( ! $ this -> isDir ( ) || ! $ this -> exists ( ) ) { return null ; } foreach ( $ this -> scanDir ( ) as $ file ) { if ( $ file -> getFileName ( ) === $ fileName ) { return $ file ; } if ( $ file -> isDir ( ) ) { $ result = $ file -> findFirstOccurenceOfFile ( $ fileName ) ; if ( $ result !== null ) { return $ result ; } } } return null ; }
Finds the first occurence of the given filename

@param string $fileName

@return null|File
Finds the first occurence of the given filename