Payment::getTotalVat()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace BWC\Share\Payment\Model;
4
5
use BWC\Share\Payment\Model\PaymentItem;
6
use BWC\Share\Object\DeserializeTrait;
7
8
class Payment
9
{
10
    use DeserializeTrait;
11
12
    /** @var  double */
13
    public $totalAmount;
14
15
    /** @var  string */
16
    public $currency;
17
18
    /** @var  string */
19
    public $description;
20
21
    /** @var PaymentItem[] */
22
    public $items = [];
23
24
25
    /**
26
     * @return double|int
27
     */
28
    public function getTotalVat()
29
    {
30
        $totalVat = 0;
31
        foreach ($this->items as $item) {
32
            $totalVat += $item->getVatAmount();
33
        }
34
        return $totalVat;
35
    }
36
37
    /**
38
     * @param array $arr
39
     */
40
    public function deserializeExtra($arr)
41
    {
42
        $this->items = [];
43
        if (isset($arr['items']) && is_array($arr['items'])) {
44
            foreach ($arr['items'] as $itemData) {
45
                $this->items[] = PaymentItem::deserialize($itemData);
46
            }
47
        }
48
    }
49
}