Test Failed
Push — master ( 87aaf6...f504c6 )
by Esteban De La Fuente
06:21 queued 01:53
created

ImpuestoAdicionalRetencion::getGlosa()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * LibreDTE: Biblioteca PHP (Núcleo).
7
 * Copyright (C) LibreDTE <https://www.libredte.cl>
8
 *
9
 * Este programa es software libre: usted puede redistribuirlo y/o modificarlo
10
 * bajo los términos de la Licencia Pública General Affero de GNU publicada por
11
 * la Fundación para el Software Libre, ya sea la versión 3 de la Licencia, o
12
 * (a su elección) cualquier versión posterior de la misma.
13
 *
14
 * Este programa se distribuye con la esperanza de que sea útil, pero SIN
15
 * GARANTÍA ALGUNA; ni siquiera la garantía implícita MERCANTIL o de APTITUD
16
 * PARA UN PROPÓSITO DETERMINADO. Consulte los detalles de la Licencia Pública
17
 * General Affero de GNU para obtener una información más detallada.
18
 *
19
 * Debería haber recibido una copia de la Licencia Pública General Affero de
20
 * GNU junto a este programa.
21
 *
22
 * En caso contrario, consulte <http://www.gnu.org/licenses/agpl.html>.
23
 */
24
25
namespace libredte\lib\Core\Package\Billing\Component\Document\Entity;
26
27
use Derafu\Lib\Core\Package\Prime\Component\Entity\Entity\Entity;
28
use Derafu\Lib\Core\Package\Prime\Component\Entity\Mapping as DEM;
29
use libredte\lib\Core\Package\Billing\Component\Document\Repository\ImpuestoAdicionalRetencionRepository;
30
31
/**
32
 * Entidad de impuesto adicional y retención.
33
 */
34
#[DEM\Entity(repositoryClass: ImpuestoAdicionalRetencionRepository::class)]
35
class ImpuestoAdicionalRetencion extends Entity
36
{
37
    /**
38
     * Obtiene el código del impuesto o retención.
39
     *
40
     * @return int
41
     */
42 1
    public function getCodigo(): int
43
    {
44 1
        return (int) $this->getAttribute('codigo');
45
    }
46
47
    /**
48
     * Obtiene el tipo de entidad: impuesto adicional o retención.
49
     *
50
     * @return string|false A: adicional, R: retención o `false` si no se pudo
51
     * determinar.
52
     */
53 6
    public function getTipo(): string|false
54
    {
55 6
        if ($this->hasAttribute('tipo')) {
56 6
            return $this->getAttribute('tipo');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getAttribute('tipo') could return the type boolean|null which is incompatible with the type-hinted return false|string. Consider adding an additional type-check to rule them out.
Loading history...
57
        }
58
59 1
        return false;
60
    }
61
62
    /**
63
     * Obtiene la glosa del impuesto adicional o retención.
64
     *
65
     * @return string Glosa del impuesto o glosa estándar si no se encontró una.
66
     */
67 1
    public function getGlosa(): string
68
    {
69 1
        if ($this->hasAttribute('glosa')) {
70 1
            return $this->getAttribute('glosa');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getAttribute('glosa') could return the type boolean|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
71
        }
72
73 1
        return 'Impto. cód. ' . $this->getCodigo();
74
    }
75
76
    /**
77
     * Obtiene la tasa del impuesto adicional o retención.
78
     *
79
     * @return float|false Tasa del impuesto o =false si no se pudo determinar.
80
     */
81 6
    public function getTasa(): float|false
82
    {
83 6
        if ($this->hasAttribute('tasa')) {
84 6
            return (float) $this->getAttribute('tasa');
85
        }
86
87 1
        return false;
88
    }
89
}
90