src/File.php
public function open(string $mode)
    {
        $read = strpbrk($mode, "r+") !== false;
        $write = strpbrk($mode, "waxc+") !== false;
        $x = strpbrk($mode, "x") !== false;

        $path = $this->getFullPath();
        $fh = @fopen($path, $mode);
        if (is_resource($fh))
            return $fh;

        if ($x && file_exists($path))
            throw new IOException("File already exists: " . $path);
        if ($write && !is_writable($path))
            throw new IOException("File is not writable: " . $path);
        if ($read && !is_readable($path))
            throw new IOException("File is not readable: " . $path);

        throw new IOException("Invalid mode for opening file: " . $mode);
    }
public function open(string $mode)
    {
        $read = strpbrk($mode, "r+") !== false;
        $write = strpbrk($mode, "waxc+") !== false;
        $x = strpbrk($mode, "x") !== false;

        $path = $this->getFullPath();
        $fh = @fopen($path, $mode);
        if (is_resource($fh))
            return $fh;

        if ($x && file_exists($path))
            throw new IOException("File already exists: " . $path);
        if ($write && !is_writable($path))
            throw new IOException("File is not writable: " . $path);
        if ($read && !is_readable($path))
            throw new IOException("File is not readable: " . $path);

        throw new IOException("Invalid mode for opening file: " . $mode);
    }
public function open ( string $ mode ) { $ read = strpbrk ( $ mode , "r+" ) !== false ; $ write = strpbrk ( $ mode , "waxc+" ) !== false ; $ x = strpbrk ( $ mode , "x" ) !== false ; $ path = $ this -> getFullPath ( ) ; $ fh = @ fopen ( $ path , $ mode ) ; if ( is_resource ( $ fh ) ) return $ fh ; if ( $ x && file_exists ( $ path ) ) throw new IOException ( "File already exists: " . $ path ) ; if ( $ write && ! is_writable ( $ path ) ) throw new IOException ( "File is not writable: " . $ path ) ; if ( $ read && ! is_readable ( $ path ) ) throw new IOException ( "File is not readable: " . $ path ) ; throw new IOException ( "Invalid mode for opening file: " . $ mode ) ; }
Open the file for reading or writing, throwing informative
exceptions when it fails.

@param string $mode The file opening mode
@return resource The opened file resource
@throws IOException When opening the file failed.
@seealso fopen
Open the file for reading or writing throwing informative exceptions when it fails .