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

NoHeaderStrategy   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 10
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getHeaders() 0 7 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