Transaction   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrency() 0 3 1
A setCurrency() 0 3 1
A getAmount() 0 3 1
A fromArray() 0 10 3
A setAmount() 0 3 1
1
<?php
2
namespace PomeloPHP\Model;
3
4
class Transaction
5
{
6
    /**
7
     * @var int
8
     */
9
    private $amount;
10
11
    /**
12
     * @var string
13
     */
14
    private $currency;
15
16
    /**
17
     * @return int
18
     */
19
    public function getAmount()
20
    {
21
        return $this->amount;
22
    }
23
24
    /**
25
     * @param int $amount
26
     */
27
    public function setAmount(int $amount)
28
    {
29
        $this->amount = $amount;
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getCurrency()
36
    {
37
        return $this->currency;
38
    }
39
40
    /**
41
     * @param string $currency
42
     */
43
    public function setCurrency(string $currency)
44
    {
45
        $this->currency = $currency;
46
    }
47
48
    /**
49
     * @param array $json
50
     * @return $this
51
     */
52
    public function fromArray(array $json)
53
    {
54
        if (array_key_exists('amount', $json) && array_key_exists('currency', $json)) {
55
            $this->amount = $json['amount'];
56
            $this->currency = $json['currency'];
57
58
            return $this;
59
        }
60
61
        throw new \InvalidArgumentException('amount and currency are required to sign a transaction');
62
    }
63
}
64