Moneda::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 6
dl 0
loc 17
ccs 8
cts 8
cp 1
crap 3
rs 10
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\Exceptions\SatCatalogosLogicException;
9
10
class Moneda extends AbstractEntryIdentifiable
11
{
12
    /** @var int */
13
    private $decimales;
14
15
    /** @var int */
16
    private $porcentajeVariacion;
17
18 4
    public function __construct(
19
        string $id,
20
        string $texto,
21
        int $decimales,
22
        int $porcentajeVariacion,
23
        int $vigenteDesde,
24
        int $vigenteHasta
25
    ) {
26 4
        parent::__construct($id, $texto, $vigenteDesde, $vigenteHasta);
27 4
        if ($decimales < 0) {
28 1
            throw new SatCatalogosLogicException('El campo decimales no puede ser menor a cero');
29
        }
30 3
        if ($porcentajeVariacion < 0) {
31 1
            throw new SatCatalogosLogicException('El campo porcentaje de variación no puede ser menor a cero');
32
        }
33 2
        $this->decimales = $decimales;
34 2
        $this->porcentajeVariacion = $porcentajeVariacion;
35
    }
36
37 1
    public function decimales(): int
38
    {
39 1
        return $this->decimales;
40
    }
41
42 1
    public function porcentajeVariacion(): int
43
    {
44 1
        return $this->porcentajeVariacion;
45
    }
46
}
47