Completed
Branch FET-10619-money-entity (f4b3f8)
by
unknown
139:32 queued 127:27
created

Currency   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 183
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

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

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A equals() 0 4 1
A code() 0 4 1
A name() 0 4 1
A plural() 0 4 1
A sign() 0 4 1
A signB4() 0 4 1
A decimalPlaces() 0 4 1
A decimalMark() 0 4 1
A thousands() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace EventEspresso\core\domain\values\currency;
4
5
use EventEspresso\core\entities\Label;
6
7
defined('EVENT_ESPRESSO_VERSION') || exit;
8
9
10
11
/**
12
 * Class Currency
13
 * DTO for data pertaining to a currency
14
 *
15
 * @package       Event Espresso
16
 * @author        Brent Christensen
17
 * @since         $VID:$
18
 */
19
class Currency
20
{
21
22
    /**
23
     * eg 'US'
24
     *
25
     * @var string $code
26
     */
27
    private $code;
28
29
    /**
30
     * @var Label $label
31
     */
32
    private $label;
33
34
    /**
35
     * currency sign
36
     *
37
     * @var string $sign
38
     * eg '$'
39
     */
40
    private $sign;
41
42
    /**
43
     * Whether the currency sign should come before the number or not
44
     *
45
     * @var boolean $sign_b4
46
     */
47
    private $sign_b4;
48
49
    /**
50
     * How many digits should come after the decimal place
51
     *
52
     * @var int $decimal_places
53
     */
54
    private $decimal_places;
55
56
    /**
57
     * Symbol to use for decimal mark
58
     *
59
     * @var string $decimal_mark
60
     * eg '.'
61
     */
62
    private $decimal_mark;
63
64
    /**
65
     * Symbol to use for thousands
66
     *
67
     * @var string $thousands
68
     * eg ','
69
     */
70
    private $thousands;
71
72
73
74
    /**
75
     * Currency constructor.
76
     *
77
     * @param string $code
78
     * @param Label  $label
79
     * @param string $sign
80
     * @param bool   $sign_b4
81
     * @param int    $decimal_places
82
     * @param string $decimal_mark
83
     * @param string $thousands
84
     */
85
    public function __construct($code, Label $label, $sign, $sign_b4, $decimal_places, $decimal_mark, $thousands)
86
    {
87
        $this->code           = $code;
88
        $this->label          = $label;
89
        $this->sign           = $sign;
90
        $this->sign_b4        = $sign_b4;
91
        $this->decimal_places = $decimal_places;
92
        $this->decimal_mark   = $decimal_mark;
93
        $this->thousands      = $thousands;
94
    }
95
96
97
98
    /**
99
     * returns true if this currency is the same as the supplied currency
100
     *
101
     * @param Currency $other
102
     * @return bool
103
     */
104
    public function equals(Currency $other)
105
    {
106
        return $this->code() === $other->code();
107
    }
108
109
110
111
    /**
112
     * @return string
113
     */
114
    public function code()
115
    {
116
        return $this->code;
117
    }
118
119
120
121
    /**
122
     * @return string
123
     */
124
    public function name()
125
    {
126
        return $this->label->singular();
127
    }
128
129
130
131
    /**
132
     * @return string
133
     */
134
    public function plural()
135
    {
136
        return $this->label->plural();
137
    }
138
139
140
141
    /**
142
     * @return string
143
     */
144
    public function sign()
145
    {
146
        return $this->sign;
147
    }
148
149
150
151
    /**
152
     * @return bool
153
     */
154
    public function signB4()
155
    {
156
        return $this->sign_b4;
157
    }
158
159
160
161
    /**
162
     * @return int
163
     */
164
    public function decimalPlaces()
165
    {
166
        return $this->decimal_places;
167
    }
168
169
170
171
    /**
172
     * @return string
173
     */
174
    public function decimalMark()
175
    {
176
        return $this->decimal_mark;
177
    }
178
179
180
181
    /**
182
     * @return string
183
     */
184
    public function thousands()
185
    {
186
        return $this->thousands;
187
    }
188
189
190
191
    /**
192
     * @return string
193
     */
194
    public function __toString()
195
    {
196
        return $this->code();
197
    }
198
199
200
201
}
202
// End of file Currency.php
203
// Location: core/entities/money/Currency.php
204