1 | <?php |
||
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 | * Used to convert between the currency's units and subunits. |
||
74 | * subunits = units * 10 to-the-power-of $subunits_ratio |
||
75 | * @var int |
||
76 | */ |
||
77 | private $subunit_order_of_mag_diff; |
||
78 | |||
79 | |||
80 | |||
81 | /** |
||
82 | * Currency constructor. |
||
83 | * |
||
84 | * @param string $code |
||
85 | * @param Label $label |
||
86 | * @param string $sign |
||
87 | * @param bool $sign_b4 |
||
88 | * @param int $decimal_places the number of decimal places to use when |
||
89 | * DISPLAYING the currency |
||
90 | * @param string $decimal_mark |
||
91 | * @param string $thousands |
||
92 | * @param int $subunit_order_of_mag_diff the difference between units and subunits |
||
93 | * is 10 to-the-power-of-this |
||
94 | */ |
||
95 | public function __construct( |
||
114 | |||
115 | |||
116 | |||
117 | /** |
||
118 | * returns true if this currency is the same as the supplied currency |
||
119 | * |
||
120 | * @param Currency $other |
||
121 | * @return bool |
||
122 | */ |
||
123 | public function equals(Currency $other) |
||
127 | |||
128 | |||
129 | |||
130 | /** |
||
131 | * @return string |
||
132 | */ |
||
133 | public function code() |
||
137 | |||
138 | |||
139 | |||
140 | /** |
||
141 | * @return string |
||
142 | */ |
||
143 | public function name() |
||
147 | |||
148 | |||
149 | |||
150 | /** |
||
151 | * @return string |
||
152 | */ |
||
153 | public function plural() |
||
157 | |||
158 | |||
159 | |||
160 | /** |
||
161 | * @return string |
||
162 | */ |
||
163 | public function sign() |
||
167 | |||
168 | |||
169 | |||
170 | /** |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function signB4() |
||
177 | |||
178 | |||
179 | |||
180 | /** |
||
181 | * @return int |
||
182 | */ |
||
183 | public function decimalPlaces() |
||
187 | |||
188 | |||
189 | |||
190 | /** |
||
191 | * @return string |
||
192 | */ |
||
193 | public function decimalMark() |
||
197 | |||
198 | |||
199 | |||
200 | /** |
||
201 | * @return string |
||
202 | */ |
||
203 | public function thousands() |
||
207 | |||
208 | |||
209 | |||
210 | /** |
||
211 | * The difference between currency units and subunits |
||
212 | * is 10-to-the-power-of-this. |
||
213 | * DecimalMark is used for display, this is used for calculations |
||
214 | * @return int |
||
215 | */ |
||
216 | public function subunitOrderOfMagnitudeDiff() |
||
220 | |||
221 | |||
222 | |||
223 | /** |
||
224 | * @return string |
||
225 | */ |
||
226 | public function __toString() |
||
230 | |||
231 | |||
232 | |||
233 | } |
||
234 | // End of file Currency.php |
||
236 |