Passed
Push — master ( 7129da...1959bc )
by Carlos C
13:39 queued 21s
created

PartesTransporte::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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
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\Ccp31\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 PartesTransporte extends AbstractCsvInjector
16
{
17 3
    public function checkHeaders(CsvFile $csv): void
18
    {
19 3
        $csv->move(3);
20 3
        $expected = [
21 3
            'Clave',
22 3
            'Descripción',
23 3
            'Fecha de inicio de vigencia',
24 3
            'Fecha de fin de vigencia',
25 3
        ];
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_31_partes_transporte', 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 2
        ]));
43
    }
44
}
45