Skip to content

Commit 721116c

Browse files
committed
Add toString method.
1 parent c08738f commit 721116c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/Money/Money.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function getCurrency()
143143

144144
/**
145145
* @param \Money\Money $addend
146-
*@return \Money\Money
146+
*@return \Money\Money
147147
*/
148148
public function add(Money $addend)
149149
{
@@ -273,4 +273,14 @@ public static function stringToUnits( $string )
273273

274274
return (int) $units;
275275
}
276+
277+
/**
278+
* Convert into formatted amount (hardcoded to USD for the time being).
279+
*
280+
* @return string
281+
*/
282+
public function __toString()
283+
{
284+
return number_format($this->amount / 100, 2);
285+
}
276286
}

0 commit comments

Comments
 (0)