Passed
Push — master ( 75ecec...113700 )
by Carlos C
01:14 queued 12s
created

FormaDePagoBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 31
ccs 4
cts 4
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\CFDI40\Builders;
6
7
use PhpCfdi\SatCatalogos\CFDI40\FormaDePago;
8
9
class FormaDePagoBuilder
10
{
11
    /**
12
     * @param string $id
13
     * @param array<string, scalar> $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
        $defaults = [
21
            'id' => $id,
22
            'texto' => $id,
23
            'esBancarizado' => false,
24
            'requiereNumeroDeOperacion' => false,
25
            'permiteBancoOrdenanteRfc' => false,
26
            'permiteCuentaOrdenante' => false,
27
            'patronCuentaOrdenante' => '',
28
            'permiteBancoBeneficiarioRfc' => false,
29
            'permiteCuentaBeneficiario' => false,
30
            'patronCuentaBeneficiario' => '',
31
            'permiteTipoCadenaPago' => false,
32
            'requiereBancoOrdenanteNombreExt' => false,
33
            'vigenteDesde' => 0,
34
            'vigenteHasta' => 0,
35
        ];
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