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

        if($this->directoryExists($name)) {
            return new Directory($path);
        }

        if($ifNotExists === Directory::GET_DIRECTORY_NOT_EXISTS_CREATE) {
            return Directory::make($path);
        }

        throw new DirectoryDoesntExist($path);
    }
public function getDirectory(string $name, int $ifNotExists = Directory::GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION) : Directory
    {
        $path = $this->getPath(). DIRECTORY_SEPARATOR .$name;

        if($this->directoryExists($name)) {
            return new Directory($path);
        }

        if($ifNotExists === Directory::GET_DIRECTORY_NOT_EXISTS_CREATE) {
            return Directory::make($path);
        }

        throw new DirectoryDoesntExist($path);
    }
public function getDirectory ( string $ name , int $ ifNotExists = Directory :: GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION ) : Directory { $ path = $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ name ; if ( $ this -> directoryExists ( $ name ) ) { return new Directory ( $ path ) ; } if ( $ ifNotExists === Directory :: GET_DIRECTORY_NOT_EXISTS_CREATE ) { return Directory :: make ( $ path ) ; } throw new DirectoryDoesntExist ( $ path ) ; }
Returns a directory from the directory.

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

* `\Alexya\FileSystem\Directory::GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION`, throws an exception (default).
* `\Alexya\FileSystem\Directory::GET_DIRECTORY_NOT_EXISTS_CREATE`, creates the directory.

@param string $name         Directory name.
@param int    $ifNotExists What to do if directory exists.

@return Directory Directory object.

@throws DirectoryDoesntExist   If $path doesn't exist as a directory.
@throws CouldntCreateDirectory If the directory can't be created.
Returns a directory from the directory .