From 7bf20b8436d5ba7518ada9bf941b977125711f77 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 11 Jun 2016 19:20:53 +0200 Subject: [PATCH] Rest tests --- Account/Account.php | 23 +++++++++++++++++++++++ Account/Group.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/Account/Account.php b/Account/Account.php index 1b66e090e..b81f27000 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -437,4 +437,27 @@ class Account $this->createdAt = $created; } + public function toArray() : array + { + return [ + 'id' => $this->id, + 'name' => [ + $this->name1, + $this->name2, + $this->name3, + ], + 'email' => $this->email, + 'login' => $this->login, + 'groups' => $this->groups, + 'permissions' => $this->permissions, + 'type' => $this->type, + 'status' => $this->status, + ]; + } + + public function __toString() + { + return json_encode($this->toArray()); + } + } diff --git a/Account/Group.php b/Account/Group.php index 85f881bcd..ebb380f52 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -77,6 +77,22 @@ class Group */ protected $permissions = []; + /** + * Created at. + * + * @var \DateTime + * @since 1.0.0 + */ + protected $createdAt = null; + + /** + * Created by. + * + * @var int + * @since 1.0.0 + */ + protected $createdBy = 0; + /** * Constructor. * @@ -85,6 +101,7 @@ class Group */ public function __construct() { + $this->createdAt = new \DateTime('now'); } /** @@ -152,4 +169,21 @@ class Group $this->description = $description; } + public function toArray() : array + { + return [ + 'id' => $this->id, + 'name' => $this->name, + 'description' => $this->description, + 'createdBy' => $this->createdBy, + 'createdAt' => $this->createdAt->format('Y-m-d H:i:s'), + 'permissions' => $this->permissions, + 'members' => $this->members, + ]; + } + + public function __toString() + { + return json_encode($this->toArray()); + } }