Passed
Push — master ( 98de4f...224db0 )
by Thiago
30s
created

Charge::setCharging()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
namespace MrPrompt\ShipmentCommon\Base;
3
4
/**
5
 * Charge
6
 *
7
 * @author Thiago Paes <[email protected]>
8
 */
9
class Charge
10
{
11
    /**
12
     * Billet
13
     *
14
     * @const string
15
     */
16
    const BILLET        = 'B';
17
18
    /**
19
     * Credit card
20
     *
21
     * @const string
22
     */
23
    const CREDIT_CARD   = 'C';
24
25
    /**
26
     * Debit on bank account
27
     *
28
     * @const string
29
     */
30
    const DEBIT         = 'D';
31
32
    /**
33
     * Energy account
34
     *
35
     * @const string
36
     */
37
    const ENERGY        = 'E';
38
39
    /**
40
     * Batch File
41
     *
42
     * @const string
43
     */
44
    const BATCH_FILE    = 'F';
45
46
    /**
47
     * Payment Slip
48
     *
49
     * @const string
50
     */
51
    const PAYMENT_SLIP  = 'P';
52
53
    /**
54
     * Charging type
55
     *
56
     * Types:
57
     *  - B = Boleto Bancário
58
     *  - E = Energia
59
     *  - C = Cartão de Crédito
60
     *  - D = Débito Automático
61
     *  - D = Arquivo de Remessa
62
     *  - P = Bloqueto
63
     *
64
     * @var string
65
     */
66
    private $charging   = self::CREDIT_CARD;
67
68
    /**
69
     * Occurrence
70
     *
71
     * @var string
72
     */
73
    private $occurrence = Occurrence::INSERT;
74
75
    /**
76
     * Valid types
77
     * 
78
     * @var array
79
     */
80
    private $validTypes = [
81
        self::BILLET,
82
        self::CREDIT_CARD,
83
        self::DEBIT,
84
        self::ENERGY,
85
        self::BATCH_FILE,
86
        self::PAYMENT_SLIP
87
    ];
88
89
    /**
90
     * @return the $charging
91
     */
92 1
    public function getCharging()
93
    {
94 1
        return $this->charging;
95
    }
96
97
    /**
98
     * @param string $charging
99
     */
100 2
    public function setCharging(string $charging)
101
    {
102 2
        if (!in_array($charging, $this->validTypes)) {
103 1
            throw new \InvalidArgumentException(sprintf('Invalid charge type: %s', $charging));
104
        }
105
106 1
        $this->charging = $charging;
107 1
    }
108
109
    /**
110
     * @return Occurrence
111
     */
112 1
    public function getOccurrence()
113
    {
114 1
        return $this->occurrence;
115
    }
116
117
    /**
118
     * @param Occurrence $occurrence
119
     */
120 1
    public function setOccurrence(Occurrence $occurrence)
121
    {
122 1
        $this->occurrence = $occurrence;
0 ignored issues
show
Documentation Bug introduced by
It seems like $occurrence of type object<MrPrompt\ShipmentCommon\Base\Occurrence> is incompatible with the declared type string of property $occurrence.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
123 1
    }
124
}
125