Currency   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 122
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 122
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrency() 0 3 1
A toArray() 0 6 1
A getCode() 0 3 1
A __construct() 0 6 1
A getNum() 0 3 1
A setNum() 0 4 1
A setCode() 0 4 1
A setCurrency() 0 4 1
1
<?php
2
/**
3
 * @category    Brownie/ExchangeRate
4
 * @author      Brownie <[email protected]>
5
 * @license     https://opensource.org/licenses/MIT
6
 */
7
8
namespace Brownie\ExchangeRate\Model;
9
10
/**
11
 * A currency model.
12
 */
13
class Currency
14
{
15
16
    /**
17
     * Currency name.
18
     *
19
     * @var string
20
     */
21
    private $currency;
22
23
    /**
24
     * Currency code.
25
     *
26
     * @var string
27
     */
28
    private $code;
29
30
    /**
31
     * Currency number.
32
     *
33
     * @var int
34
     */
35
    private $num;
36
37
    /**
38
     * Sets the input values.
39
     *
40
     * @param string    $currency   Currency name.
41
     * @param string    $code       Currency code.
42
     * @param int       $num        Currency number.
43
     */
44 2
    public function __construct($currency, $code, $num)
45
    {
46
        $this
47 2
            ->setCurrency($currency)
48 2
            ->setCode($code)
49 2
            ->setNum($num);
50 2
    }
51
52
    /**
53
     * Sets currency name.
54
     * Returns the current object.
55
     *
56
     * @param string    $currency   Currency name.
57
     *
58
     * @return self
59
     */
60 2
    private function setCurrency($currency)
61
    {
62 2
        $this->currency = $currency;
63 2
        return $this;
64
    }
65
66
    /**
67
     * Sets currency code.
68
     * Returns the current object.
69
     *
70
     * @param string    $code   Currency code.
71
     *
72
     * @return self
73
     */
74 2
    private function setCode($code)
75
    {
76 2
        $this->code = $code;
77 2
        return $this;
78
    }
79
80
    /**
81
     * Sets currency number.
82
     * Returns the current object.
83
     *
84
     * @param int   $num    Currency number.
85
     *
86
     * @return self
87
     */
88 2
    private function setNum($num)
89
    {
90 2
        $this->num = $num;
91 2
        return $this;
92
    }
93
94
    /**
95
     * Gets currency name.
96
     *
97
     * @return string
98
     */
99 2
    public function getCurrency()
100
    {
101 2
        return $this->currency;
102
    }
103
104
    /**
105
     * Gets currency code.
106
     *
107
     * @return string
108
     */
109 2
    public function getCode()
110
    {
111 2
        return $this->code;
112
    }
113
114
    /**
115
     * Gets currency number.
116
     *
117
     * @return int
118
     */
119 2
    public function getNum()
120
    {
121 2
        return $this->num;
122
    }
123
124
    /**
125
     * Gets currency data as an associative array.
126
     *
127
     * @return array
128
     */
129 2
    public function toArray()
130
    {
131
        return [
132 2
            'currency' => $this->getCurrency(),
133 2
            'code' => $this->getCode(),
134 2
            'num' => $this->getNum(),
135
        ];
136
    }
137
}
138