Commit fff3d842 authored by Thorsten Buss's avatar Thorsten Buss

allow money obj as $amount

parent 840e81d6
......@@ -38,8 +38,14 @@ class Money implements \JsonSerializable, Jsonable, Arrayable {
* @throws MoneyException
*/
public function __construct($amount, $currency=null) {
if (empty($amount)) // FIX: if something empty is given (empty string, null, 0.0 etc) everything shoul work the same
// FIX: if $amount is a money obj
if ($amount instanceof Money)
$amount = $amount->value();
// FIX: if something empty is given (empty string, null, 0.0 etc) everything shoul work the same
if (empty($amount))
$amount = 0;
if (!is_int($amount) && !ctype_digit($amount)) {
throw new MoneyException('Amount must be an integer');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment