protected function getCode($path, $line, $numLines)
    {
        if (empty($path) || empty($line) || !file_exists($path)) {
            return;
        }

        try {
            $file = new SplFileObject($path);
            $file->seek(PHP_INT_MAX);

            $bounds = static::getBounds($line, $numLines, $file->key() + 1);

            $code = [];

            $file->seek($bounds[0] - 1);
            while ($file->key() < $bounds[1]) {
                $code[$file->key() + 1] = rtrim(substr($file->current(), 0, static::MAX_LENGTH));
                $file->next();
            }

            return $code;
        } catch (RuntimeException $ex) {
            // do nothing
        }
    }
protected function getCode($path, $line, $numLines)
    {
        if (empty($path) || empty($line) || !file_exists($path)) {
            return;
        }

        try {
            $file = new SplFileObject($path);
            $file->seek(PHP_INT_MAX);

            $bounds = static::getBounds($line, $numLines, $file->key() + 1);

            $code = [];

            $file->seek($bounds[0] - 1);
            while ($file->key() < $bounds[1]) {
                $code[$file->key() + 1] = rtrim(substr($file->current(), 0, static::MAX_LENGTH));
                $file->next();
            }

            return $code;
        } catch (RuntimeException $ex) {
            // do nothing
        }
    }
protected function getCode ( $ path , $ line , $ numLines ) { if ( empty ( $ path ) || empty ( $ line ) || ! file_exists ( $ path ) ) { return ; } try { $ file = new SplFileObject ( $ path ) ; $ file -> seek ( PHP_INT_MAX ) ; $ bounds = static :: getBounds ( $ line , $ numLines , $ file -> key ( ) + 1 ) ; $ code = [ ] ; $ file -> seek ( $ bounds [ 0 ] - 1 ) ; while ( $ file -> key ( ) < $ bounds [ 1 ] ) { $ code [ $ file -> key ( ) + 1 ] = rtrim ( substr ( $ file -> current ( ) , 0 , static :: MAX_LENGTH ) ) ; $ file -> next ( ) ; } return $ code ; } catch ( RuntimeException $ ex ) { // do nothing } }
Extract the code for the given file and lines.

@param string $path     the path to the file
@param int    $line     the line to centre about
@param string $numLines the number of lines to fetch

@return string[]|null
Extract the code for the given file and lines .