public function parse(\SplFileObject $file = null, $optFlags = null, $rewind = null)
    {
        //Prepare passed options
        $file = ($file !== null) ? $file : $this->file;
        $optFlags = ($optFlags !== null) ? $optFlags : $this->mode;
        $rewind = ($rewind !== null) ? !!$rewind : $this->rewind;

        if (!$file instanceof \SplFileObject) {
            throw new Exception(".htaccess file is not set. You must set it (with Prser::setFile) before calling parse");
        }

        if (!$file->isReadable()) {
            $path = $file->getRealPath();
            throw new Exception(".htaccess file '$path'' is not readable");
        }

        // Rewind file pointer
        if ($rewind) {
            $file->rewind();
        }

        // Current Parse Mode
        $this->_cpMode = $optFlags;

        // Modes
        $asArray = (AS_ARRAY & $optFlags);

        // Container
        if ($asArray) {
            $htaccess = array();
        } else {
            $htaccess = ($this->container != null) ? $this->container : new HtaccessContainer();
        }

        //Dump file line by line into $htaccess
        while ($file->valid()) {

            //Get line
            $line = $file->getCurrentLine();

            //Parse Line
            $parsedLine = $this->parseLine($line, $file);

            if (!is_null($parsedLine)) {
                $htaccess[] = $parsedLine;
            }
        }

        return $htaccess;
    }
public function parse(\SplFileObject $file = null, $optFlags = null, $rewind = null)
    {
        //Prepare passed options
        $file = ($file !== null) ? $file : $this->file;
        $optFlags = ($optFlags !== null) ? $optFlags : $this->mode;
        $rewind = ($rewind !== null) ? !!$rewind : $this->rewind;

        if (!$file instanceof \SplFileObject) {
            throw new Exception(".htaccess file is not set. You must set it (with Prser::setFile) before calling parse");
        }

        if (!$file->isReadable()) {
            $path = $file->getRealPath();
            throw new Exception(".htaccess file '$path'' is not readable");
        }

        // Rewind file pointer
        if ($rewind) {
            $file->rewind();
        }

        // Current Parse Mode
        $this->_cpMode = $optFlags;

        // Modes
        $asArray = (AS_ARRAY & $optFlags);

        // Container
        if ($asArray) {
            $htaccess = array();
        } else {
            $htaccess = ($this->container != null) ? $this->container : new HtaccessContainer();
        }

        //Dump file line by line into $htaccess
        while ($file->valid()) {

            //Get line
            $line = $file->getCurrentLine();

            //Parse Line
            $parsedLine = $this->parseLine($line, $file);

            if (!is_null($parsedLine)) {
                $htaccess[] = $parsedLine;
            }
        }

        return $htaccess;
    }
public function parse ( \ SplFileObject $ file = null , $ optFlags = null , $ rewind = null ) { //Prepare passed options $ file = ( $ file !== null ) ? $ file : $ this -> file ; $ optFlags = ( $ optFlags !== null ) ? $ optFlags : $ this -> mode ; $ rewind = ( $ rewind !== null ) ? ! ! $ rewind : $ this -> rewind ; if ( ! $ file instanceof \ SplFileObject ) { throw new Exception ( ".htaccess file is not set. You must set it (with Prser::setFile) before calling parse" ) ; } if ( ! $ file -> isReadable ( ) ) { $ path = $ file -> getRealPath ( ) ; throw new Exception ( ".htaccess file '$path'' is not readable" ) ; } // Rewind file pointer if ( $ rewind ) { $ file -> rewind ( ) ; } // Current Parse Mode $ this -> _cpMode = $ optFlags ; // Modes $ asArray = ( AS_ARRAY & $ optFlags ) ; // Container if ( $ asArray ) { $ htaccess = array ( ) ; } else { $ htaccess = ( $ this -> container != null ) ? $ this -> container : new HtaccessContainer ( ) ; } //Dump file line by line into $htaccess while ( $ file -> valid ( ) ) { //Get line $ line = $ file -> getCurrentLine ( ) ; //Parse Line $ parsedLine = $ this -> parseLine ( $ line , $ file ) ; if ( ! is_null ( $ parsedLine ) ) { $ htaccess [ ] = $ parsedLine ; } } return $ htaccess ; }
Parse a .htaccess file

@api
@param \SplFileObject $file [optional] The .htaccess file. If null is passed and the file wasn't previously
set, it will raise an exception
@param int $optFlags [optional] Option flags
- IGNORE_WHITELINES  [2] Ignores whitelines (default)
- IGNORE_COMMENTS    [4] Ignores comments
@param bool $rewind [optional] If the file pointer should be moved to the start (default is true)
@return array|\ArrayAccess|HtaccessContainer
@throws Exception
Parse a . htaccess file