File: LineGenerator.php Lines 2 to 21
2namespace Puyo\File\Generator;
3
4class LineGenerator {
5    /**
6     * ファイルを1行ずつ返すgenerator
7     * @param $fullpath
8     * @return \Generator
9     */
10    static public function eachLine($fullpath) {
Type Class Description
pmd ShortVariable Avoid variables with short names like $fp. Configured minimum length is 3.
11
Type Class Description
pmd ShortVariable Avoid variables with short names like $fp. Configured minimum length is 3.
        $fp = @fopen($fullpath, 'rb');
12        if($fp === false) {
13            throw new \RuntimeException("cannot open stream: $fullpath");
14        }
15        try {
16            while (false !== $line = fgets($fp)) {
17                yield $line;
18            }
19        } finally {
20            @fclose($fp);
21        }