AbstractEntryIdentifiable::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
c 0
b 0
f 0
nc 3
nop 4
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\SatCatalogos\Common;
6
7
use PhpCfdi\SatCatalogos\Exceptions\SatCatalogosLogicException;
8
9
abstract class AbstractEntryIdentifiable implements EntryIdentifiable
10
{
11
    use EntryWithVigenciasTrait;
12
13
    /** @var string */
14
    private $id;
15
16
    /** @var string */
17
    private $texto;
18
19 232
    public function __construct(string $id, string $texto, int $vigenteDesde, int $vigenteHasta)
20
    {
21 232
        if ('' === $id) {
22 1
            throw new SatCatalogosLogicException('El campo ID no puede ser una cadena de caracteres vacía');
23
        }
24 231
        if ('' === $texto) {
25 1
            throw new SatCatalogosLogicException('El campo texto no puede ser una cadena de caracteres vacía');
26
        }
27 230
        $this->id = $id;
28 230
        $this->texto = $texto;
29 230
        $this->setUpVigencias($vigenteDesde, $vigenteHasta);
30
    }
31
32 123
    public function id(): string
33
    {
34 123
        return $this->id;
35
    }
36
37 83
    public function texto(): string
38
    {
39 83
        return $this->texto;
40
    }
41
}
42