CsvFileReader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 9
c 1
b 0
f 1
dl 0
loc 15
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A read() 0 13 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Dictionary\Infrastructure\FileReader;
6
7
use App\Dictionary\Features\PopulateStorage\FileReader\FileReaderInterface;
8
use App\Dictionary\Features\PopulateStorage\FileReader\OpenFileException;
9
use Generator;
10
11
final class CsvFileReader implements FileReaderInterface
12
{
13
    public function read(string $filePath): Generator
14
    {
15
        try {
16
            $file = fopen($filePath, 'rb');
17
            if (!$file) {
0 ignored issues
show
introduced by
$file is of type resource, thus it always evaluated to false.
Loading history...
18
                throw new OpenFileException($filePath);
19
            }
20
21
            while (!feof($file)) {
22
                yield fgetcsv($file);
23
            }
24
        } finally {
25
            $file && fclose($file);
26
        }
27
    }
28
}
29