diff --git a/src/MessageBird/Objects/Message.php b/src/MessageBird/Objects/Message.php index 6873bff7..f36b1b07 100644 --- a/src/MessageBird/Objects/Message.php +++ b/src/MessageBird/Objects/Message.php @@ -127,9 +127,9 @@ class Message extends Base /** * An array of recipients * - * @var array + * @var Recipients */ - public $recipients = array (); + public $recipients; /** * The URL to send status delivery reports for the message to @@ -225,14 +225,8 @@ public function loadFromArray ($object) { parent::loadFromArray($object); - if (!empty($this->recipients->items)) { - foreach($this->recipients->items AS &$item) { - $Recipient = new Recipient(); - $Recipient->loadFromArray($item); - - $item = $Recipient; - } - } + $recipients = new Recipients(); + $this->recipients = $recipients->loadFromArray($this->recipients); return $this; } diff --git a/src/MessageBird/Objects/Recipient.php b/src/MessageBird/Objects/Recipient.php index cf14d92d..44c86415 100644 --- a/src/MessageBird/Objects/Recipient.php +++ b/src/MessageBird/Objects/Recipient.php @@ -35,4 +35,28 @@ class Recipient extends Base * @var string */ public $statusDatetime; + + /** + * @return int + */ + public function getRecipient() + { + return $this->recipient; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @return string + */ + public function getStatusDatetime() + { + return $this->statusDatetime; + } } diff --git a/src/MessageBird/Objects/Recipients.php b/src/MessageBird/Objects/Recipients.php new file mode 100644 index 00000000..dc0fe88c --- /dev/null +++ b/src/MessageBird/Objects/Recipients.php @@ -0,0 +1,97 @@ +totalCount; + } + + /** + * @return int + */ + public function getTotalSentCount() + { + return $this->totalSentCount; + } + + /** + * @return int + */ + public function getTotalDeliveredCount() + { + return $this->totalDeliveredCount; + } + + /** + * @return int + */ + public function getTotalDeliveryFailedCount() + { + return $this->totalDeliveryFailedCount; + } + + /** + * @return Recipient[] + */ + public function getItems() + { + return $this->items; + } + + /** + * @param $object + * + * @return $this|void + */ + public function loadFromArray($object) + { + parent::loadFromArray($object); + + if (!empty($this->items)) { + foreach ($this->items as &$item) { + $recipient = new Recipient(); + $recipient->loadFromArray($item); + + $item = $recipient; + } + } + + return $this; + } +}