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

ConfiguracionesAutotransporte::checkHeaders()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 13
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 19
ccs 15
cts 15
cp 1
crap 2
rs 9.8333
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\IntegerDataField;
12
use PhpCfdi\SatCatalogosPopulate\Database\TextDataField;
13
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile;
14
use RuntimeException;
15
16
class ConfiguracionesAutotransporte extends AbstractCsvInjector
17
{
18 3
    public function checkHeaders(CsvFile $csv): void
19
    {
20 3
        $csv->move(3);
21 3
        $expected = [
22 3
            'Clave nomenclatura',
23 3
            'Descripción',
24 3
            'Número de ejes',
25 3
            'Número de llantas',
26 3
            'Remolque',
27 3
            'Fecha de inicio de vigencia',
28 3
            'Fecha de fin de vigencia',
29 3
        ];
30 3
        $headers = $csv->readLine();
31
32 3
        if ($expected !== $headers) {
33 1
            throw new RuntimeException("The headers did not match on file {$this->sourceFile()}");
34
        }
35
36 2
        $csv->next();
37
    }
38
39 2
    public function dataTable(): DataTable
40
    {
41 2
        return new DataTable('ccp_31_configuraciones_autotransporte', new DataFields([
42 2
            new TextDataField('id'),
43 2
            new TextDataField('texto'),
44 2
            new IntegerDataField('numero_de_ejes'),
45 2
            new IntegerDataField('numero_de_llantas'),
46 2
            new TextDataField('remolque'), // 1 | 1,0 | 0
47 2
            new DateDataField('vigencia_desde'),
48 2
            new DateDataField('vigencia_hasta'),
49 2
        ]));
50
    }
51
}
52