File: CsvLineGenerator.php Lines 2 to 21
2namespace Puyo\File\Generator;
3
4class CsvLineGenerator {
5    /**
6     * CSVを1行ずつ返すgenerator
7     * @param string $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 = fgetcsv($fp)) {
17                yield $line;
18            }
19        } finally {
20            fclose($fp);
21        }