Failed Conditions
Pull Request — master (#31)
by Chad
01:33
created

NoHeaderStrategy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeaders() 0 7 1
A isHeaderRow() 0 4 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
    public function isHeaderRow(array $row) : bool
21
    {
22
        return false;
23
    }
24
}
25