Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Commit

Permalink
Add __toString()
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardojbaez committed Jul 25, 2016
1 parent d5cfb20 commit 4506863
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ echo moneyFormat(1000000, 'INR'); // RESULT: र10,00,000
<?php

$money = new Gerardojbaez\Money\Money(1000000, 'INR');
ehco $money->format(); // RESULT: र10,00,000

echo $money->format(); // RESULT: र10,00,000
echo $money; // The same as using $money->format()

echo $money->amount(); // RESULT: 10,00,000
```

Expand Down
10 changes: 10 additions & 0 deletions src/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ function __construct($amount, $currency = 'USD')
$this->currency = (is_string($currency) ? new Currency($currency) : $currency);
}

/**
* Print formated amount.
*
* @return string
*/
public function __toString()
{
return $this->format();
}

/**
* Format amount to currency equivalent string.
*
Expand Down

0 comments on commit 4506863

Please sign in to comment.