Passed
Push — master ( dbb7af...afc37d )
by Carlos C
02:39 queued 11s
created

Percepciones::addPercepcion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace CfdiUtils\Elements\Nomina12;
4
5
use CfdiUtils\Elements\Common\AbstractElement;
6
7
class Percepciones extends AbstractElement
8
{
9 8
    public function getElementName(): string
10
    {
11 8
        return 'nomina12:Percepciones';
12
    }
13
14 8
    public function getChildrenOrder(): array
15
    {
16
        return [
17 8
            'nomina12:Percepcion',
18
            'nomina12:JubilacionPensionRetiro',
19
            'nomina12:SeparacionIndemnizacion',
20
        ];
21
    }
22
23 2
    public function addPercepcion(array $attributes, array $children = []): Percepcion
24
    {
25 2
        $percepcion = new Percepcion($attributes, $children);
26 2
        $this->addChild($percepcion);
27 2
        return $percepcion;
28
    }
29
30 1
    public function multiPercepcion(array ...$elementAttributes): self
31
    {
32 1
        foreach ($elementAttributes as $attributes) {
33 1
            $this->addPercepcion($attributes);
34
        }
35 1
        return $this;
36
    }
37
38 2
    public function getJubilacionPensionRetiro(): JubilacionPensionRetiro
39
    {
40
        /** @noinspection PhpIncompatibleReturnTypeInspection */
41 2
        return $this->helperGetOrAdd(new JubilacionPensionRetiro());
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->helperGetO...ilacionPensionRetiro()) could return the type CfdiUtils\Elements\Nomina12\Percepciones which is incompatible with the type-hinted return CfdiUtils\Elements\Nomin...JubilacionPensionRetiro. Consider adding an additional type-check to rule them out.
Loading history...
42
    }
43
44 1
    public function addJubilacionPensionRetiro(array $attributes = []): JubilacionPensionRetiro
45
    {
46 1
        $jubilacionPensionRetiro = $this->getJubilacionPensionRetiro();
47 1
        $jubilacionPensionRetiro->addAttributes($attributes);
48 1
        return $jubilacionPensionRetiro;
49
    }
50
51 2
    public function getSeparacionIndemnizacion(): SeparacionIndemnizacion
52
    {
53
        /** @noinspection PhpIncompatibleReturnTypeInspection */
54 2
        return $this->helperGetOrAdd(new SeparacionIndemnizacion());
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->helperGetO...aracionIndemnizacion()) could return the type CfdiUtils\Elements\Nomina12\Percepciones which is incompatible with the type-hinted return CfdiUtils\Elements\Nomin...SeparacionIndemnizacion. Consider adding an additional type-check to rule them out.
Loading history...
55
    }
56
57 1
    public function addSeparacionIndemnizacion(array $attributes = []): SeparacionIndemnizacion
58
    {
59 1
        $separacionIndemnizacion = $this->getSeparacionIndemnizacion();
60 1
        $separacionIndemnizacion->addAttributes($attributes);
61 1
        return $separacionIndemnizacion;
62
    }
63
}
64