Passed
Push — master ( b455bd...aef189 )
by João
02:57
created

PIS::getCST()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gbbs\NfeCalculos;
6
7
use Gbbs\NfeCalculos\Exception\InvalidCSTException;
8
use Gbbs\NfeCalculos\Exception\NotImplementedCSTException;
9
10
class PIS
11
{
12
    public $CST;
13
    public $vBC;
14
    public $pPIS;
15
    public $vPIS;
16
    public $qBCProd;
17
    public $vAliqProd;
18
}
19
20
/**
21
 * @param PIS $PIS
22
 * @return PIS
23
 * @throws NotImplementedCSTException|InvalidCSTException
24
 */
25
function calcularPIS(PIS $PIS)
26
{
27
    /* Operação Tributável com Alíquota Básica */
28 34
    if ($PIS->CST === '01') {
29 1
        return adValoremPIS($PIS);
30 33
    } elseif ($PIS->CST === '02') {
31 1
        throw new NotImplementedCSTException($PIS->CST);
32 32
    } elseif ($PIS->CST === '03') {
33 1
        throw new NotImplementedCSTException($PIS->CST);
34 31
    } elseif ($PIS->CST === '04') {
35 1
        throw new NotImplementedCSTException($PIS->CST);
36 30
    } elseif ($PIS->CST === '05') {
37 1
        throw new NotImplementedCSTException($PIS->CST);
38 29
    } elseif ($PIS->CST === '06') {
39 1
        throw new NotImplementedCSTException($PIS->CST);
40 28
    } elseif ($PIS->CST === '07') {
41 1
        throw new NotImplementedCSTException($PIS->CST);
42 27
    } elseif ($PIS->CST === '08') {
43 1
        throw new NotImplementedCSTException($PIS->CST);
44 26
    } elseif ($PIS->CST === '09') {
45 1
        throw new NotImplementedCSTException($PIS->CST);
46 25
    } elseif ($PIS->CST === '49') {
47 1
        throw new NotImplementedCSTException($PIS->CST);
48 24
    } elseif ($PIS->CST === '50') {
49 1
        throw new NotImplementedCSTException($PIS->CST);
50 23
    } elseif ($PIS->CST === '51') {
51 1
        throw new NotImplementedCSTException($PIS->CST);
52 22
    } elseif ($PIS->CST === '52') {
53 1
        throw new NotImplementedCSTException($PIS->CST);
54 21
    } elseif ($PIS->CST === '53') {
55 1
        throw new NotImplementedCSTException($PIS->CST);
56 20
    } elseif ($PIS->CST === '54') {
57 1
        throw new NotImplementedCSTException($PIS->CST);
58 19
    } elseif ($PIS->CST === '55') {
59 1
        throw new NotImplementedCSTException($PIS->CST);
60 18
    } elseif ($PIS->CST === '56') {
61 1
        throw new NotImplementedCSTException($PIS->CST);
62 17
    } elseif ($PIS->CST === '60') {
63 1
        throw new NotImplementedCSTException($PIS->CST);
64 16
    } elseif ($PIS->CST === '61') {
65 1
        throw new NotImplementedCSTException($PIS->CST);
66 15
    } elseif ($PIS->CST === '62') {
67 1
        throw new NotImplementedCSTException($PIS->CST);
68 14
    } elseif ($PIS->CST === '63') {
69 1
        throw new NotImplementedCSTException($PIS->CST);
70 13
    } elseif ($PIS->CST === '64') {
71 1
        throw new NotImplementedCSTException($PIS->CST);
72 12
    } elseif ($PIS->CST === '65') {
73 1
        throw new NotImplementedCSTException($PIS->CST);
74 11
    } elseif ($PIS->CST === '66') {
75 1
        throw new NotImplementedCSTException($PIS->CST);
76 10
    } elseif ($PIS->CST === '67') {
77 1
        throw new NotImplementedCSTException($PIS->CST);
78 9
    } elseif ($PIS->CST === '70') {
79 1
        throw new NotImplementedCSTException($PIS->CST);
80 8
    } elseif ($PIS->CST === '71') {
81 1
        throw new NotImplementedCSTException($PIS->CST);
82 7
    } elseif ($PIS->CST === '72') {
83 1
        throw new NotImplementedCSTException($PIS->CST);
84 6
    } elseif ($PIS->CST === '73') {
85 1
        throw new NotImplementedCSTException($PIS->CST);
86 5
    } elseif ($PIS->CST === '74') {
87 1
        throw new NotImplementedCSTException($PIS->CST);
88 4
    } elseif ($PIS->CST === '75') {
89 1
        throw new NotImplementedCSTException($PIS->CST);
90 3
    } elseif ($PIS->CST === '98') {
91 1
        throw new NotImplementedCSTException($PIS->CST);
92 2
    } elseif ($PIS->CST === '99') {
93 1
        throw new NotImplementedCSTException($PIS->CST);
94
    }
95 1
    throw new InvalidCSTException($PIS->CST);
96
}
97
98
/**
99
 * @param PIS $PIS
100
 * @return PIS
101
 */
102
function adValoremPIS(PIS $PIS)
103
{
104 1
    $pPIS = 0.65;
105 1
    $calculado = new PIS();
106 1
    $calculado->CST = $PIS->CST;
107 1
    $calculado->vBC = $PIS->vBC;
108 1
    $calculado->pPIS = $pPIS;
109 1
    $calculado->vPIS = $PIS->vBC * ($pPIS / 100);
110 1
    return $calculado;
111
}
112