public static function make(string $path, int $ifExists = File::MAKE_FILE_EXISTS_THROW_EXCEPTION) : File
    {
        $exists = File::exists($path);

        if($exists) {
            if($ifExists === File::MAKE_FILE_EXISTS_OVERWRITE) {
                unlink($path);
            } else if($ifExists === File::MAKE_FILE_EXISTS_OPEN) {
                return new File($path);
            } else {
                throw new FileAlreadyExists($path);
            }
        }

        if(!fopen($path, "c")) {
            throw new CouldntCreateFile($path);
        }

        return new File($path);
    }
public static function make(string $path, int $ifExists = File::MAKE_FILE_EXISTS_THROW_EXCEPTION) : File
    {
        $exists = File::exists($path);

        if($exists) {
            if($ifExists === File::MAKE_FILE_EXISTS_OVERWRITE) {
                unlink($path);
            } else if($ifExists === File::MAKE_FILE_EXISTS_OPEN) {
                return new File($path);
            } else {
                throw new FileAlreadyExists($path);
            }
        }

        if(!fopen($path, "c")) {
            throw new CouldntCreateFile($path);
        }

        return new File($path);
    }
public static function make ( string $ path , int $ ifExists = File :: MAKE_FILE_EXISTS_THROW_EXCEPTION ) : File { $ exists = File :: exists ( $ path ) ; if ( $ exists ) { if ( $ ifExists === File :: MAKE_FILE_EXISTS_OVERWRITE ) { unlink ( $ path ) ; } else if ( $ ifExists === File :: MAKE_FILE_EXISTS_OPEN ) { return new File ( $ path ) ; } else { throw new FileAlreadyExists ( $ path ) ; } } if ( ! fopen ( $ path , "c" ) ) { throw new CouldntCreateFile ( $ path ) ; } return new File ( $ path ) ; }
Makes a file.

The second parameter specifies what to do in case file already exists:

* `\Alexya\FileSystem\File::MAKE_FILE_EXISTS_THROW_EXCEPTION`, throws an exception (default).
* `\Alexya\FileSystem\File::MAKE_FILE_EXISTS_OVERWRITE`, deletes the file and recreates it.
* `\Alexya\FileSystem\File::MAKE_FILE_EXISTS_OPEN`, opens the file.

@param string $path     Path to the file.
@param int    $ifExists What to do if file exists.

@return File File object.

@throws FileAlreadyExists If $path already exists as a file.
@throws CouldntCreateFile If the file can't be created.
Makes a file .