FormaDePagoBuilder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 19
c 1
b 0
f 1
dl 0
loc 31
ccs 20
cts 20
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 24 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\SatCatalogos\CFDI\Builders;
6
7
use PhpCfdi\SatCatalogos\CFDI\FormaDePago;
8
9
class FormaDePagoBuilder
10
{
11
    /**
12
     * @param string $id
13
     * @param array<string, mixed> $values
14
     * @return FormaDePago
15
     */
16 15
    public function make(string $id, array $values): FormaDePago
17
    {
18 15
        unset($values['id']);
19
        // the order of the arguments **must** be the same as in FormaDePago constructor
20 15
        $defaults = [
21 15
            'id' => $id,
22 15
            'texto' => $id,
23 15
            'esBancarizado' => false,
24 15
            'requiereNumeroDeOperacion' => false,
25 15
            'permiteBancoOrdenanteRfc' => false,
26 15
            'permiteCuentaOrdenante' => false,
27 15
            'patronCuentaOrdenante' => '',
28 15
            'permiteBancoBeneficiarioRfc' => false,
29 15
            'permiteCuentaBeneficiario' => false,
30 15
            'patronCuentaBeneficiario' => '',
31 15
            'permiteTipoCadenaPago' => false,
32 15
            'requiereBancoOrdenanteNombreExt' => false,
33 15
            'vigenteDesde' => 0,
34 15
            'vigenteHasta' => 0,
35 15
        ];
36
37 15
        $values = array_values(array_intersect_key(array_merge($defaults, $values), $defaults));
38
39 15
        return new FormaDePago(...$values); /** @phpstan-ignore-line */
40
    }
41
}
42