public function openFileAsArray(string $filepath):array
    {
        if ($filepath == $this->filepath && $this->file != null) {
            return ($this->file);
        }

        if (!file_exists($filepath)) {
            Server::create($filepath, 'file');
        }

        if (!is_readable($filepath)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Cannot open file $filepath : File not readable",
                "solution" => "Please set the readable permission")));
        }

        $this->perm = null;
        $this->filepath = $filepath;
        $this->file = file($filepath);

        if (!is_array($this->file)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Invalid file array for $filepath",
                "solution" =>
                    "Use FileListener::open to open a file resource.")));
        }

        return ($this->file);
    }
public function openFileAsArray(string $filepath):array
    {
        if ($filepath == $this->filepath && $this->file != null) {
            return ($this->file);
        }

        if (!file_exists($filepath)) {
            Server::create($filepath, 'file');
        }

        if (!is_readable($filepath)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Cannot open file $filepath : File not readable",
                "solution" => "Please set the readable permission")));
        }

        $this->perm = null;
        $this->filepath = $filepath;
        $this->file = file($filepath);

        if (!is_array($this->file)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Invalid file array for $filepath",
                "solution" =>
                    "Use FileListener::open to open a file resource.")));
        }

        return ($this->file);
    }
public function openFileAsArray ( string $ filepath ) : array { if ( $ filepath == $ this -> filepath && $ this -> file != null ) { return ( $ this -> file ) ; } if ( ! file_exists ( $ filepath ) ) { Server :: create ( $ filepath , 'file' ) ; } if ( ! is_readable ( $ filepath ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Cannot open file $filepath : File not readable" , "solution" => "Please set the readable permission" ) ) ) ; } $ this -> perm = null ; $ this -> filepath = $ filepath ; $ this -> file = file ( $ filepath ) ; if ( ! is_array ( $ this -> file ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Invalid file array for $filepath" , "solution" => "Use FileListener::open to open a file resource." ) ) ) ; } return ( $ this -> file ) ; }
Open file and returning an array of each line
@param $filepath string Filepath
@return array File array content
@throws Server500|\Exception If file does not exist or not readable | If cannot create file
Open file and returning an array of each line