Payment   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 42
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTotalVat() 0 8 2
A deserializeExtra() 0 9 4
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
}