Skip to content

Commit 87847a0

Browse files
committed
Tweak __toString and add format()
1 parent d1a6860 commit 87847a0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/Money/Money.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,18 @@ public static function stringToUnits( $string )
274274
return (int) $units;
275275
}
276276

277+
public function format()
278+
{
279+
return '$' . number_format($this->getAmount() / 100, 2, '.', '');
280+
}
281+
277282
/**
278283
* Convert into formatted amount (hardcoded to USD for the time being).
279284
*
280285
* @return string
281286
*/
282287
public function __toString()
283288
{
284-
return '$' . number_format($this->amount / 100, 2);
289+
return number_format($this->getAmount() / 100, 2);
285290
}
286291
}

0 commit comments

Comments
 (0)