<?php namespace Ctct\Components\EmailMarketing; use Ctct\Components\Component; class TestSend extends Component { public $format; public $personal_message; public $email_addresses = array(); public static function create(array $props) { $test_send = new TestSend(); $test_send->format = parent::getValue($props, "format"); $test_send->personal_message = parent::getValue($props, "personal_message"); foreach ($props['email_addresses'] as $email_address) { $test_send->email_addresses[] = $email_address; } return $test_send; } public function addEmail($email_address) { $this->email_addresses[] = $email_address; } public function toJson() { $testsend = clone $this; if ($testsend->personal_message == null) { unset($testsend->personal_message); } return json_encode($testsend); } } 