Passed
Pull Request — master (#14)
by
unknown
02:43
created

NumerosPedimentoAduana   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 27
ccs 11
cts 11
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 3
A obtain() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\SatCatalogos\CFDI40;
6
7
use PhpCfdi\SatCatalogos\Common\BaseCatalog;
8
use PhpCfdi\SatCatalogos\Common\BaseCatalogTrait;
9
use PhpCfdi\SatCatalogos\Repository;
10
11
class NumerosPedimentoAduana implements BaseCatalog
12
{
13
    use BaseCatalogTrait;
14
15 2
    public function obtain(string $aduana, string $patente, int $ejercicio): NumeroPedimentoAduana
16
    {
17 2
        $data = $this->repository()->queryRowByFields(Repository::CFDI_40_NUMEROS_PEDIMENTO_ADUANA, [
18
            'aduana' => $aduana,
19
            'patente' => $patente,
20
            'ejercicio' => $ejercicio,
21
        ]);
22 2
        return $this->create($data);
23
    }
24
25
    /**
26
     * @param array<string, mixed> $data
27
     * @return NumeroPedimentoAduana
28
     */
29 3
    public function create(array $data): NumeroPedimentoAduana
30
    {
31 3
        return new NumeroPedimentoAduana(
32 3
            (string) $data['aduana'],
33 3
            (string) $data['patente'],
34 3
            (int) $data['ejercicio'],
35 3
            (int) $data['cantidad'],
36 3
            ($data['vigencia_desde']) ? strtotime($data['vigencia_desde']) : 0,
37 3
            ($data['vigencia_hasta']) ? strtotime($data['vigencia_hasta']) : 0
38
        );
39
    }
40
}
41