public function getFile(string $name, int $ifNotExists = Directory::GET_FILE_NOT_EXISTS_THROW_EXCEPTION) : File
    {
        $path = $this->getPath(). DIRECTORY_SEPARATOR .$name;

        if($this->fileExists($name)) {
            return new File($path);
        }

        if($ifNotExists === Directory::GET_FILE_NOT_EXISTS_CREATE) {
            $this->_files[$name] = $name;

            return File::make($path, File::MAKE_FILE_EXISTS_OPEN);
        }

        throw new FileDoesntExist($path);
    }
public function getFile(string $name, int $ifNotExists = Directory::GET_FILE_NOT_EXISTS_THROW_EXCEPTION) : File
    {
        $path = $this->getPath(). DIRECTORY_SEPARATOR .$name;

        if($this->fileExists($name)) {
            return new File($path);
        }

        if($ifNotExists === Directory::GET_FILE_NOT_EXISTS_CREATE) {
            $this->_files[$name] = $name;

            return File::make($path, File::MAKE_FILE_EXISTS_OPEN);
        }

        throw new FileDoesntExist($path);
    }
public function getFile ( string $ name , int $ ifNotExists = Directory :: GET_FILE_NOT_EXISTS_THROW_EXCEPTION ) : File { $ path = $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ name ; if ( $ this -> fileExists ( $ name ) ) { return new File ( $ path ) ; } if ( $ ifNotExists === Directory :: GET_FILE_NOT_EXISTS_CREATE ) { $ this -> _files [ $ name ] = $ name ; return File :: make ( $ path , File :: MAKE_FILE_EXISTS_OPEN ) ; } throw new FileDoesntExist ( $ path ) ; }
Returns a file from the directory.

The second parameter specifies what to do in case file doesn't exist:

* `\Alexya\FileSystem\Directory::GET_FILE_NOT_EXISTS_THROW_EXCEPTION`, throws an exception (default).
* `\Alexya\FileSystem\Directory::GET_FILE_NOT_EXISTS_CREATE`, creates the file.

@param string $name         File name.
@param int    $ifNotExists What to do if file exists.

@return File File object.

@throws FileDoesntExist   If $path doesn't exist as a file.
@throws CouldntCreateFile If the file can't be created.
Returns a file from the directory .