From 2cf6969cfb904d26c1a0a9c2beb560a9db7d3bbc Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 2 Jul 2016 20:01:55 +0200 Subject: [PATCH] Implement json serialize --- Account/Account.php | 15 ++++++++++++++- Account/Group.php | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Account/Account.php b/Account/Account.php index 0da17b984..9714da3c3 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -31,7 +31,7 @@ use phpOMS\Validation\Base\Email; * @link http://orange-management.com * @since 1.0.0 */ -class Account implements ArrayableInterface +class Account implements ArrayableInterface, \JsonSerializable { /** @@ -468,6 +468,19 @@ class Account implements ArrayableInterface * @author Dennis Eichhorn */ public function __toString() + { + return $this->jsonSerialize(); + } + + /** + * Json serialize. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function jsonSerialize() { return json_encode($this->toArray()); } diff --git a/Account/Group.php b/Account/Group.php index a9507ca6c..dbaef5473 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -27,7 +27,7 @@ use phpOMS\Contract\ArrayableInterface; * @link http://orange-management.com * @since 1.0.0 */ -class Group implements ArrayableInterface +class Group implements ArrayableInterface, \JsonSerializable { /** @@ -195,6 +195,19 @@ class Group implements ArrayableInterface * @author Dennis Eichhorn */ public function __toString() + { + return $this->jsonSerialize(); + } + + /** + * Json serialize. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function jsonSerialize() { return json_encode($this->toArray()); }