Completed
Push — master ( 4bb787...bf6574 )
by Tobias
01:45
created

DetailedSums::createFromArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 15
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Model\Invoice;
6
7
use Billogram\Model\CreatableFromArray;
8
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class DetailedSums implements CreatableFromArray
13
{
14
    /**
15
     * @var float
16
     */
17
    private $invoiceFee;
18
19
    /**
20
     * @var float
21
     */
22
    private $invoiceFeeVat;
23
24
    /**
25
     * @var float
26
     */
27
    private $netSum;
28
29
    /**
30
     * @var float
31
     */
32
    private $vatSum;
33
34
    /**
35
     * @var float
36
     */
37
    private $grossSum;
38
39
    /**
40
     * @var float
41
     */
42
    private $rounding;
43
44
    /**
45
     * @var float
46
     */
47
    private $reminderFee;
48
49
    /**
50
     * @var float
51
     */
52
    private $interestFee;
53
54
    /**
55
     * @var float
56
     */
57
    private $paidSum;
58
59
    /**
60
     * @var float
61
     */
62
    private $collectorPaidSum;
63
64
    /**
65
     * @var float
66
     */
67
    private $remainingSum;
68
69
    /**
70
     * @return float
71
     */
72
    public function getInvoiceFee(): float
73
    {
74
        return $this->invoiceFee;
75
    }
76
77
    /**
78
     * @param float $invoiceFee
79
     *
80
     * @return DetailedSums
81
     */
82
    public function withInvoiceFee(float $invoiceFee)
83
    {
84
        $new = clone $this;
85
        $new->invoiceFee = $invoiceFee;
86
87
        return $new;
88
    }
89
90
    /**
91
     * @return float
92
     */
93
    public function getInvoiceFeeVat(): float
94
    {
95
        return $this->invoiceFeeVat;
96
    }
97
98
    /**
99
     * @param float $invoiceFeeVat
100
     *
101
     * @return DetailedSums
102
     */
103
    public function withInvoiceFeeVat(float $invoiceFeeVat)
104
    {
105
        $new = clone $this;
106
        $new->invoiceFeeVat = $invoiceFeeVat;
107
108
        return $new;
109
    }
110
111
    /**
112
     * @return float
113
     */
114
    public function getNetSum(): float
115
    {
116
        return $this->netSum;
117
    }
118
119
    /**
120
     * @param float $netSum
121
     *
122
     * @return DetailedSums
123
     */
124
    public function wiNetSum(float $netSum)
125
    {
126
        $new = clone $this;
127
        $new->netSum = $netSum;
128
129
        return $new;
130
    }
131
132
    /**
133
     * @return float
134
     */
135
    public function getVatSum(): float
136
    {
137
        return $this->vatSum;
138
    }
139
140
    /**
141
     * @param float $vatSum
142
     *
143
     * @return DetailedSums
144
     */
145
    public function withVatSum(float $vatSum)
146
    {
147
        $new = clone $this;
148
        $new->vatSum = $vatSum;
149
150
        return $new;
151
    }
152
153
    /**
154
     * @return float
155
     */
156
    public function getGrossSum(): float
157
    {
158
        return $this->grossSum;
159
    }
160
161
    /**
162
     * @param float $grossSum
163
     *
164
     * @return DetailedSums
165
     */
166
    public function withGrossSum(float $grossSum)
167
    {
168
        $new = clone $this;
169
        $new->grossSum = $grossSum;
170
171
        return $new;
172
    }
173
174
    /**
175
     * @return float
176
     */
177
    public function getRounding(): float
178
    {
179
        return $this->rounding;
180
    }
181
182
    /**
183
     * @param float $rounding
184
     *
185
     * @return DetailedSums
186
     */
187
    public function withRounding(float $rounding)
188
    {
189
        $new = clone $this;
190
        $new->rounding = $rounding;
191
192
        return $new;
193
    }
194
195
    /**
196
     * @return float
197
     */
198
    public function getReminderFee(): float
199
    {
200
        return $this->reminderFee;
201
    }
202
203
    /**
204
     * @param float $reminderFee
205
     *
206
     * @return DetailedSums
207
     */
208
    public function withReminderFee(float $reminderFee)
209
    {
210
        $new = clone $this;
211
        $new->reminderFee = $reminderFee;
212
213
        return $new;
214
    }
215
216
    /**
217
     * @return float
218
     */
219
    public function getInterestFee(): float
220
    {
221
        return $this->interestFee;
222
    }
223
224
    /**
225
     * @param float $interestFee
226
     *
227
     * @return DetailedSums
228
     */
229
    public function withInterestFee(float $interestFee)
230
    {
231
        $new = clone $this;
232
        $new->interestFee = $interestFee;
233
234
        return $new;
235
    }
236
237
    /**
238
     * @return float
239
     */
240
    public function getPaidSum(): float
241
    {
242
        return $this->paidSum;
243
    }
244
245
    /**
246
     * @param float $paidSum
247
     *
248
     * @return DetailedSums
249
     */
250
    public function withPaidSum(float $paidSum)
251
    {
252
        $new = clone $this;
253
        $new->paidSum = $paidSum;
254
255
        return $new;
256
    }
257
258
    /**
259
     * @return float
260
     */
261
    public function getCollectorPaidSum(): float
262
    {
263
        return $this->collectorPaidSum;
264
    }
265
266
    /**
267
     * @param float $collectorPaidSum
268
     *
269
     * @return DetailedSums
270
     */
271
    public function withCollectorPaidSum(float $collectorPaidSum)
272
    {
273
        $new = clone $this;
274
        $new->collectorPaidSum = $collectorPaidSum;
275
276
        return $new;
277
    }
278
279
    /**
280
     * @return float
281
     */
282
    public function getRemainingSum(): float
283
    {
284
        return $this->remainingSum;
285
    }
286
287
    /**
288
     * @param float $remainingSum
289
     *
290
     * @return DetailedSums
291
     */
292
    public function withRemainingSum(float $remainingSum)
293
    {
294
        $new = clone $this;
295
        $new->remainingSum = $remainingSum;
296
297
        return $new;
298
    }
299
300
    public function toArray()
301
    {
302
        $data = [];
303
        if ($this->invoiceFee !== null) {
304
            $data['invoice_fee'] = $this->invoiceFee;
305
        }
306
        if ($this->invoiceFeeVat !== null) {
307
            $data['invoice_fee_vat'] = $this->invoiceFeeVat;
308
        }
309
        if ($this->netSum !== null) {
310
            $data['net_sum'] = $this->netSum;
311
        }
312
        if ($this->vatSum !== null) {
313
            $data['vat_sum'] = $this->vatSum;
314
        }
315
        if ($this->grossSum !== null) {
316
            $data['gross_sum'] = $this->grossSum;
317
        }
318
        if ($this->rounding !== null) {
319
            $data['rounding'] = $this->rounding;
320
        }
321
        if ($this->reminderFee !== null) {
322
            $data['reminder_fee'] = $this->reminderFee;
323
        }
324
        if ($this->interestFee !== null) {
325
            $data['interest_fee'] = $this->interestFee;
326
        }
327
        if ($this->paidSum !== null) {
328
            $data['paid_sum'] = $this->paidSum;
329
        }
330
        if ($this->collectorPaidSum !== null) {
331
            $data['collector_paid_sum'] = $this->collectorPaidSum;
332
        }
333
        if ($this->remainingSum !== null) {
334
            $data['remaining_sum'] = $this->remainingSum;
335
        }
336
    }
337
338
    /**
339
     * Create an API response object from the HTTP response from the API server.
340
     *
341
     * @param array $data
342
     *
343
     * @return self
344
     */
345
    public static function createFromArray(array $data)
346
    {
347
        $detail = new self();
348
        $detail->invoiceFee = $data['invoice_fee'] ?? null;
349
        $detail->invoiceFeeVat = $data['invoice_fee_vat'] ?? null;
350
        $detail->netSum = $data['net_sum'] ?? null;
351
        $detail->vatSum = $data['vat_sum'] ?? null;
352
        $detail->grossSum = $data['gross_sum'] ?? null;
353
        $detail->rounding = $data['rounding'] ?? null;
354
        $detail->reminderFee = $data['reminder_fee'] ?? null;
355
        $detail->interestFee = $data['interest_fee'] ?? null;
356
        $detail->paidSum = $data['paid_sum'] ?? null;
357
        $detail->collectorPaidSum = $data['collector_paid_sum'] ?? null;
358
359
        return $detail;
360
    }
361
}
362