Completed
Pull Request — master (#31)
by Chad
01:29
created

NoHeaderStrategy::getHeaders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace SubjectivePHP\Csv;
4
5
use SplFileObject;
6
7
/**
8
 * Header strategy which generates a numeric array whose size is the number of columns in the given file.
9
 */
10
final class NoHeaderStrategy implements HeaderStrategyInterface
11
{
12
    public function getHeaders(SplFileObject $fileObject) : array
13
    {
14
        $firstRow = $fileObject->fgetcsv();
15
        $headers = array_keys($firstRow);
16
        $fileObject->rewind();
17
        return $headers;
18
    }
19
}
20