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

DeriveHeaderStrategy::getHeaders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace SubjectivePHP\Csv;
4
5
use SplFileObject;
6
7
/**
8
 * Header strategy which derives the headers from the first line of the file.
9
 */
10
final class DeriveHeaderStrategy implements HeaderStrategyInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    private $headers;
16
17
    /**
18
     * Extracts headers from the given SplFileObject.
19
     *
20
     * @param SplFileObject $fileObject The delimited file containing the headers.
21
     *
22
     * @return array
23
     */
24
    public function getHeaders(SplFileObject $fileObject) : array
25
    {
26
        $this->headers = $fileObject->fgetcsv();
27
        $fileObject->rewind();
28
        return $this->headers;
29
    }
30
}
31