PreApproval::setMaxTotalAmount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace PHPSC\PagSeguro\Requests\PreApprovals;
3
4
use DateTime;
5
use InvalidArgumentException;
6
use JMS\Serializer\Annotation as Serializer;
7
use PHPSC\PagSeguro\SerializerTrait;
8
9
/**
10
 * @Serializer\AccessType("public_method")
11
 * @Serializer\ReadOnly
12
 * @Serializer\XmlRoot("preApproval")
13
 *
14
 * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
15
 */
16
class PreApproval
17
{
18
    use SerializerTrait;
19
20
    /**
21
     * @Serializer\XmlElement(cdata=false)
22
     *
23
     * @var string
24
     */
25
    private $name;
26
27
    /**
28
     * @Serializer\SerializedName("charge")
29
     * @Serializer\XmlElement(cdata=false)
30
     *
31
     * @var string
32
     */
33
    private $chargeType;
34
35
    /**
36
     * @Serializer\XmlElement(cdata=false)
37
     *
38
     * @var string
39
     */
40
    private $details;
41
42
    /**
43
     * @Serializer\XmlElement(cdata=false)
44
     *
45
     * @var string
46
     */
47
    private $period;
48
49
    /**
50
     * @Serializer\Type("DateTime<'Y-m-d\TH:i:sP'>")
51
     * @Serializer\XmlElement(cdata=false)
52
     *
53
     * @var DateTime
54
     */
55
    private $finalDate;
56
57
    /**
58
     * @Serializer\XmlElement(cdata=false)
59
     *
60
     * @var float
61
     */
62
    private $maxTotalAmount;
63
64
    /**
65
     * @Serializer\XmlElement(cdata=false)
66
     *
67
     * @var float
68
     */
69
    private $amountPerPayment;
70
71
    /**
72
     * @Serializer\XmlElement(cdata=false)
73
     *
74
     * @var float
75
     */
76
    private $maxAmountPerPayment;
77
78
    /**
79
     * @Serializer\Type("integer")
80
     *
81
     * @var int
82
     */
83
    private $maxPaymentsPerPeriod;
84
85
    /**
86
     * @Serializer\XmlElement(cdata=false)
87
     *
88
     * @var float
89
     */
90
    private $maxAmountPerPeriod;
91
92
    /**
93
     * @Serializer\Type("DateTime<'Y-m-d\TH:i:sP','00:00'>")
94
     * @Serializer\XmlElement(cdata=false)
95
     *
96
     * @var DateTime
97
     */
98
    private $initialDate;
99
100
    /**
101
     * @return string
102
     */
103 2
    public function getName()
104
    {
105 2
        return $this->name;
106
    }
107
108
    /**
109
     * @param string $name
110
     */
111 2
    public function setName($name)
112
    {
113 2
        $this->name = $name;
114 2
    }
115
116
    /**
117
     * @return string
118
     */
119 2
    public function getChargeType()
120
    {
121 2
        return $this->chargeType;
122
    }
123
124
    /**
125
     * @param string $chargeType
126
     *
127
     * @throws InvalidArgumentException
128
     */
129 4
    public function setChargeType($chargeType)
130
    {
131 4
        if (!ChargeType::isValid($chargeType)) {
132 1
            throw new InvalidArgumentException('You should inform a valid charge type');
133
        }
134
135 3
        $this->chargeType = $chargeType;
136 3
    }
137
138
    /**
139
     * @return string
140
     */
141 2
    public function getDetails()
142
    {
143 2
        return $this->details;
144
    }
145
146
    /**
147
     * @param string $details
148
     */
149 2
    public function setDetails($details)
150
    {
151 2
        $this->details = $details;
152 2
    }
153
154
    /**
155
     * @return string
156
     */
157 2
    public function getPeriod()
158
    {
159 2
        return $this->period;
160
    }
161
162
    /**
163
     * @param string $period
164
     *
165
     * @throws InvalidArgumentException
166
     */
167 3
    public function setPeriod($period)
168
    {
169 3
        if (!Period::isValid($period)) {
170 1
            throw new InvalidArgumentException('You should inform a valid period');
171
        }
172
173 2
        $this->period = $period;
174 2
    }
175
176
    /**
177
     * @return DateTime
178
     */
179 2
    public function getFinalDate()
180
    {
181 2
        return $this->finalDate;
182
    }
183
184
    /**
185
     * @param DateTime $finalDate
186
     */
187 2
    public function setFinalDate(DateTime $finalDate)
188
    {
189 2
        $this->finalDate = $finalDate;
190 2
    }
191
192
    /**
193
     * @return string
194
     */
195 2
    public function getMaxTotalAmount()
196
    {
197 2
        return $this->formatAmount($this->maxTotalAmount);
198
    }
199
200
    /**
201
     * @param float $maxTotalAmount
202
     */
203 2
    public function setMaxTotalAmount($maxTotalAmount)
204
    {
205 2
        $this->maxTotalAmount = $maxTotalAmount;
206 2
    }
207
208
    /**
209
     * @return string
210
     */
211 2
    public function getAmountPerPayment()
212
    {
213 2
        return $this->formatAmount($this->amountPerPayment);
214
    }
215
216
    /**
217
     * @param float $amountPerPayment
218
     */
219 2
    public function setAmountPerPayment($amountPerPayment)
220
    {
221 2
        $this->amountPerPayment = $amountPerPayment;
222 2
    }
223
    /**
224
     * @return string
225
     */
226 2
    public function getMaxAmountPerPayment()
227
    {
228 2
        return $this->formatAmount($this->maxAmountPerPayment);
229
    }
230
231
    /**
232
     * @param float $maxAmountPerPayment
233
     */
234 2
    public function setMaxAmountPerPayment($maxAmountPerPayment)
235
    {
236 2
        $this->maxAmountPerPayment = $maxAmountPerPayment;
237 2
    }
238
239
    /**
240
     * @return int
241
     */
242 2
    public function getMaxPaymentsPerPeriod()
243
    {
244 2
        return $this->maxPaymentsPerPeriod;
245
    }
246
247
    /**
248
     * @param int $maxPaymentsPerPeriod
249
     */
250 2
    public function setMaxPaymentsPerPeriod($maxPaymentsPerPeriod)
251
    {
252 2
        $this->maxPaymentsPerPeriod = $maxPaymentsPerPeriod;
253 2
    }
254
255
    /**
256
     * @return string
257
     */
258 2
    public function getMaxAmountPerPeriod()
259
    {
260 2
        return $this->formatAmount($this->maxAmountPerPeriod);
261
    }
262
263
    /**
264
     * @param float $maxAmountPerPeriod
265
     */
266 2
    public function setMaxAmountPerPeriod($maxAmountPerPeriod)
267
    {
268 2
        $this->maxAmountPerPeriod = $maxAmountPerPeriod;
269 2
    }
270
271
    /**
272
     * @return DateTime
273
     */
274 2
    public function getInitialDate()
275
    {
276 2
        return $this->initialDate;
277
    }
278
279
    /**
280
     * @param DateTime $initialDate
281
     */
282 2
    public function setInitialDate(DateTime $initialDate)
283
    {
284 2
        $this->initialDate = $initialDate;
285 2
    }
286
}
287