public function read(string $filename): array
    {
        $lines = ['total' => 0, 'read' => 0];

        // Open file as SPL object
        $file = new \SplFileObject($filename);

        // Read line by line
        while (!$file->eof()) {
            $line = $file->fgets();
            // Save line only of not empty
            if ($this->isLine($line) && \strlen($line) > 1) {
                $line = trim(preg_replace('/\s+/', ' ', $line));
                $this->_lines[] = $line;
                $lines['read']++;
            }
            $lines['total']++;
        }
        return $lines;
    }
public function read(string $filename): array
    {
        $lines = ['total' => 0, 'read' => 0];

        // Open file as SPL object
        $file = new \SplFileObject($filename);

        // Read line by line
        while (!$file->eof()) {
            $line = $file->fgets();
            // Save line only of not empty
            if ($this->isLine($line) && \strlen($line) > 1) {
                $line = trim(preg_replace('/\s+/', ' ', $line));
                $this->_lines[] = $line;
                $lines['read']++;
            }
            $lines['total']++;
        }
        return $lines;
    }
public function read ( string $ filename ) : array { $ lines = [ 'total' => 0 , 'read' => 0 ] ; // Open file as SPL object $ file = new \ SplFileObject ( $ filename ) ; // Read line by line while ( ! $ file -> eof ( ) ) { $ line = $ file -> fgets ( ) ; // Save line only of not empty if ( $ this -> isLine ( $ line ) && \ strlen ( $ line ) > 1 ) { $ line = trim ( preg_replace ( '/\s+/' , ' ' , $ line ) ) ; $ this -> _lines [ ] = $ line ; $ lines [ 'read' ] ++ ; } $ lines [ 'total' ] ++ ; } return $ lines ; }
Read configuration file line by line

@param   string $filename
@return  array Array with count of total and read lines
Read configuration file line by line