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

FormaDePago::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 14
dl 0
loc 27
ccs 12
cts 12
cp 1
crap 1
rs 9.9

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\SatCatalogos\CFDI40;
6
7
use PhpCfdi\SatCatalogos\Common\AbstractEntryIdentifiable;
8
use PhpCfdi\SatCatalogos\Common\EntryIdentifiable;
9
use PhpCfdi\SatCatalogos\Helpers\Patron;
10
11
class FormaDePago extends AbstractEntryIdentifiable implements EntryIdentifiable
12
{
13
    /** @var bool */
14
    private $esBancarizado;
15
16
    /** @var bool */
17
    private $requiereNumeroDeOperacion;
18
19
    /** @var bool */
20
    private $permiteBancoOrdenanteRfc;
21
22
    /** @var bool */
23
    private $permiteCuentaOrdenante;
24
25
    /** @var Patron */
26
    private $patronCuentaOrdenante;
27
28
    /** @var bool */
29
    private $permiteBancoBeneficiarioRfc;
30
31
    /** @var bool */
32
    private $permiteCuentaBeneficiario;
33
34
    /** @var Patron */
35
    private $patronCuentaBeneficiario;
36
37
    /** @var bool */
38
    private $permiteTipoCadenaPago;
39
40
    /** @var bool */
41
    private $requiereBancoOrdenanteNombreExt;
42
43 17
    public function __construct(
44
        string $id,
45
        string $texto,
46
        bool $esBancarizado,
47
        bool $requiereNumeroDeOperacion,
48
        bool $permiteBancoOrdenanteRfc,
49
        bool $permiteCuentaOrdenante,
50
        string $patronCuentaOrdenante,
51
        bool $permiteBancoBeneficiarioRfc,
52
        bool $permiteCuentaBeneficiario,
53
        string $patronCuentaBeneficiario,
54
        bool $permiteTipoCadenaPago,
55
        bool $requiereBancoOrdenanteNombreExt,
56
        int $vigenteDesde,
57
        int $vigenteHasta
58
    ) {
59 17
        parent::__construct($id, $texto, $vigenteDesde, $vigenteHasta);
60 17
        $this->esBancarizado = $esBancarizado;
61 17
        $this->requiereNumeroDeOperacion = $requiereNumeroDeOperacion;
62 17
        $this->permiteBancoOrdenanteRfc = $permiteBancoOrdenanteRfc;
63 17
        $this->permiteCuentaOrdenante = $permiteCuentaOrdenante;
64 17
        $this->patronCuentaOrdenante = new Patron($patronCuentaOrdenante, Patron::VACIO_PERMITE_NADA);
65 17
        $this->permiteBancoBeneficiarioRfc = $permiteBancoBeneficiarioRfc;
66 17
        $this->permiteCuentaBeneficiario = $permiteCuentaBeneficiario;
67 17
        $this->patronCuentaBeneficiario = new Patron($patronCuentaBeneficiario, Patron::VACIO_PERMITE_NADA);
68 17
        $this->permiteTipoCadenaPago = $permiteTipoCadenaPago;
69 17
        $this->requiereBancoOrdenanteNombreExt = $requiereBancoOrdenanteNombreExt;
70
    }
71
72 3
    public function esBancarizado(): bool
73
    {
74 3
        return $this->esBancarizado;
75
    }
76
77 2
    public function requiereNumeroDeOperacion(): bool
78
    {
79 2
        return $this->requiereNumeroDeOperacion;
80
    }
81
82 1
    public function permiteBancoOrdenanteRfc(): bool
83
    {
84 1
        return $this->permiteBancoOrdenanteRfc;
85
    }
86
87 1
    public function permiteCuentaOrdenante(): bool
88
    {
89 1
        return $this->permiteCuentaOrdenante;
90
    }
91
92 2
    public function patronCuentaOrdenante(): Patron
93
    {
94 2
        return $this->patronCuentaOrdenante;
95
    }
96
97 1
    public function permiteBancoBeneficiarioRfc(): bool
98
    {
99 1
        return $this->permiteBancoBeneficiarioRfc;
100
    }
101
102 1
    public function permiteCuentaBeneficiario(): bool
103
    {
104 1
        return $this->permiteCuentaBeneficiario;
105
    }
106
107 2
    public function patronCuentaBeneficiario(): Patron
108
    {
109 2
        return $this->patronCuentaBeneficiario;
110
    }
111
112 1
    public function permiteTipoCadenaPago(): bool
113
    {
114 1
        return $this->permiteTipoCadenaPago;
115
    }
116
117 1
    public function requiereBancoOrdenanteNombreExt(): bool
118
    {
119 1
        return $this->requiereBancoOrdenanteNombreExt;
120
    }
121
}
122