src/Files.php
/**
     * Get the file data.
     * If enable, lock file to preserve atomicity
     *
     * @param string $path The file path
     * @param int $line The line to read. If -1 read the whole file
     * @return string
     */
Get the file data.
If enable, lock file to preserve atomicity

@param string $path The file path
@param int $line The line to read. If -1 read the whole file
@return string
Get the file data . If enable lock file to preserve atomicity @param string $path The file path @param int $line The line to read . If - 1 read the whole file @return string
protected function readFile($path, $line = -1)
    {
        $handle = fopen($path, 'r');
        if ($this->getOption('locking')) {
            flock($handle, LOCK_SH);
        }
        if (-1 === $line) {
            $data = stream_get_contents($handle);
        } else {
            for ($read = 1; $read < $line; $read++) {
                fgets($handle);
            }
            $data = rtrim(fgets($handle), PHP_EOL);
        }
        if ($this->getOption('locking')) {
            flock($handle, LOCK_UN);
        }
        fclose($handle);
        return $data;
    }
protected function readFile ( $ path , $ line = - 1 ) { $ handle = fopen ( $ path , 'r' ) ; if ( $ this -> getOption ( 'locking' ) ) { flock ( $ handle , LOCK_SH ) ; } if ( - 1 === $ line ) { $ data = stream_get_contents ( $ handle ) ; } else { for ( $ read = 1 ; $ read < $ line ; $ read ++ ) { fgets ( $ handle ) ; } $ data = rtrim ( fgets ( $ handle ) , PHP_EOL ) ; } if ( $ this -> getOption ( 'locking' ) ) { flock ( $ handle , LOCK_UN ) ; } fclose ( $ handle ) ; return $ data ; }
Get the file data.
Get the file data .