Passed
Push — master ( ff529b...67c449 )
by Derek Stephen
12:22
created

AbstractCsvFixtureLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCsvFixtureData() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bone\BoneDoctrine\Fixture;
6
7
use League\Csv\Reader;
8
9
abstract class AbstractCsvFixtureLoader
10
{
11
    protected function getCsvFixtureData(): \Iterator
12
    {
13
        $file = $this->getCsvFileName();
14
15
        if (!file_exists($file)) {
16
            throw new \InvalidArgumentException($file . ' does not exist.');
17
        }
18
19
        $csv = Reader::createFromPath($file);
20
        $csv->setHeaderOffset(0);
21
        $header = $csv->getHeader();
22
        $records = $csv->getRecords($header);
23
        $records->rewind();
24
25
        return $records;
26
    }
27
28
    abstract public function getCsvFileName(): string;
29
}
30
31