File tree 2 files changed +22
-6
lines changed
src/Omnipay/Common/Message
tests/Omnipay/Common/Message
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -172,12 +172,7 @@ public function getAmount()
172
172
);
173
173
}
174
174
175
- return number_format (
176
- $ amount ,
177
- $ this ->getCurrencyDecimalPlaces (),
178
- '. ' ,
179
- ''
180
- );
175
+ return $ this ->formatCurrency ($ amount );
181
176
}
182
177
}
183
178
@@ -222,6 +217,16 @@ private function getCurrencyDecimalFactor()
222
217
return pow (10 , $ this ->getCurrencyDecimalPlaces ());
223
218
}
224
219
220
+ public function formatCurrency ($ amount )
221
+ {
222
+ return number_format (
223
+ $ amount ,
224
+ $ this ->getCurrencyDecimalPlaces (),
225
+ '. ' ,
226
+ ''
227
+ );
228
+ }
229
+
225
230
public function getDescription ()
226
231
{
227
232
return $ this ->getParameter ('description ' );
Original file line number Diff line number Diff line change @@ -140,6 +140,17 @@ public function testCurrencyDecimals()
140
140
$ this ->assertSame (0 , $ this ->request ->getCurrencyDecimalPlaces ());
141
141
}
142
142
143
+ public function testFormatCurrency ()
144
+ {
145
+ $ this ->assertSame ('1234.00 ' , $ this ->request ->formatCurrency (1234 ));
146
+ }
147
+
148
+ public function testFormatCurrencyNoDecimals ()
149
+ {
150
+ $ this ->request ->setCurrency ('JPY ' );
151
+ $ this ->assertSame ('1234 ' , $ this ->request ->formatCurrency (1234 ));
152
+ }
153
+
143
154
public function testDescription ()
144
155
{
145
156
$ this ->assertSame ($ this ->request , $ this ->request ->setDescription ('Cool product ' ));
You can’t perform that action at this time.
0 commit comments