-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9291cb
commit 95f130a
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
* | ||
* @author Semenov Alexander <[email protected]> | ||
*/ | ||
class Money extends BaseObject | ||
class Money extends BaseObject implements \JsonSerializable | ||
{ | ||
/** | ||
* @var string | ||
|
@@ -202,4 +202,27 @@ public function convertToCurrency($currencyTo) | |
throw new InvalidArgumentException(\Yii::t('skeeks/money', 'Unable to get the cross rate for the currency') . ' ' . $currencyTo->code); | ||
} | ||
} | ||
|
||
/** | ||
* Specify data which should be serialized to JSON | ||
* | ||
* @return mixed data which can be serialized by <b>json_encode</b>, | ||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php | ||
*/ | ||
public function jsonSerialize() | ||
{ | ||
return [ | ||
'amount' => $this->amount, | ||
'currency' => $this->currency->code | ||
]; | ||
} | ||
|
||
/** | ||
* @return string | ||
* @deprecated | ||
*/ | ||
public function getValue() | ||
{ | ||
return $this->amount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters