protected static function highlightCode(string $file, int $line, int $padding = 6) : array
    {
        if ( ! is_readable($file)) {
            return false;
        }

        $handle      = fopen($file, 'r');
        $lines       = array();
        $currentLine = 0;

        while ( ! feof($handle)) {
            $currentLine++;

            $temp = fgets($handle);

            if ($currentLine > $line + $padding) {
                break; // Exit loop after we have found what we were looking for
            }

            if ($currentLine >= ($line - $padding) && $currentLine <= ($line + $padding)) {
                $lines[] = array
                (
                    'number'      => str_pad($currentLine, 4, ' ', STR_PAD_LEFT),
                    'highlighted' => ($currentLine === $line),
                    'code'        => ErrorHandler::highlightString($temp),
                );
            }
        }

        fclose($handle);

        return $lines;
    }
protected static function highlightCode(string $file, int $line, int $padding = 6) : array
    {
        if ( ! is_readable($file)) {
            return false;
        }

        $handle      = fopen($file, 'r');
        $lines       = array();
        $currentLine = 0;

        while ( ! feof($handle)) {
            $currentLine++;

            $temp = fgets($handle);

            if ($currentLine > $line + $padding) {
                break; // Exit loop after we have found what we were looking for
            }

            if ($currentLine >= ($line - $padding) && $currentLine <= ($line + $padding)) {
                $lines[] = array
                (
                    'number'      => str_pad($currentLine, 4, ' ', STR_PAD_LEFT),
                    'highlighted' => ($currentLine === $line),
                    'code'        => ErrorHandler::highlightString($temp),
                );
            }
        }

        fclose($handle);

        return $lines;
    }
protected static function highlightCode ( string $ file , int $ line , int $ padding = 6 ) : array { if ( ! is_readable ( $ file ) ) { return false ; } $ handle = fopen ( $ file , 'r' ) ; $ lines = array ( ) ; $ currentLine = 0 ; while ( ! feof ( $ handle ) ) { $ currentLine ++ ; $ temp = fgets ( $ handle ) ; if ( $ currentLine > $ line + $ padding ) { break ; // Exit loop after we have found what we were looking for } if ( $ currentLine >= ( $ line - $ padding ) && $ currentLine <= ( $ line + $ padding ) ) { $ lines [ ] = array ( 'number' => str_pad ( $ currentLine , 4 , ' ' , STR_PAD_LEFT ) , 'highlighted' => ( $ currentLine === $ line ) , 'code' => ErrorHandler :: highlightString ( $ temp ) , ) ; } } fclose ( $ handle ) ; return $ lines ; }
Returns an array of lines from a file.

@param  string $file    File in which you want to highlight a line
@param  int    $line    Line number to highlight
@param  int    $padding (optional) Number of padding lines
@return array
Returns an array of lines from a file .