Passed
Push — master ( e5cdcf...8113ff )
by Carlos C
02:33 queued 11s
created

ContenedoresMaritimos::dataTable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\SatCatalogosPopulate\Importers\Ccp20\Injectors;
6
7
use PhpCfdi\SatCatalogosPopulate\AbstractCsvInjector;
8
use PhpCfdi\SatCatalogosPopulate\Database\DataFields;
9
use PhpCfdi\SatCatalogosPopulate\Database\DataTable;
10
use PhpCfdi\SatCatalogosPopulate\Database\DateDataField;
11
use PhpCfdi\SatCatalogosPopulate\Database\TextDataField;
12
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile;
13
use RuntimeException;
14
15
class ContenedoresMaritimos extends AbstractCsvInjector
16
{
17 3
    public function checkHeaders(CsvFile $csv): void
18
    {
19 3
        $csv->move(3);
20 3
        $expected = [
21
            'Clave del contenedor marítimo',
22
            'Descripción',
23
            'Fecha de inicio de vigencia',
24
            'Fecha de fin de vigencia',
25
        ];
26 3
        $headers = $csv->readLine();
27
28 3
        if ($expected !== $headers) {
29 1
            throw new RuntimeException("The headers did not match on file {$this->sourceFile()}");
30
        }
31
32 2
        $csv->next();
33
    }
34
35 2
    public function dataTable(): DataTable
36
    {
37 2
        return new DataTable('ccp_20_contenedores_maritimos', new DataFields([
38 2
            new TextDataField('id'),
39 2
            new TextDataField('texto'),
40 2
            new DateDataField('vigencia_desde'),
41 2
            new DateDataField('vigencia_hasta'),
42
        ]));
43
    }
44
}
45