1 | <?php |
||
5 | class MessagebirdMessage |
||
6 | { |
||
7 | public $body; |
||
8 | public $originator; |
||
9 | public $recipients; |
||
10 | public $reference; |
||
11 | |||
12 | 2 | public static function create($body = '') |
|
16 | |||
17 | 12 | public function __construct($body = '') |
|
18 | { |
||
19 | 12 | if (! empty($body)) { |
|
20 | 6 | $this->body = trim($body); |
|
21 | } |
||
22 | 12 | } |
|
23 | |||
24 | 1 | public function setBody($body) |
|
30 | |||
31 | 4 | public function setOriginator($originator) |
|
37 | |||
38 | 7 | public function setRecipients($recipients) |
|
39 | { |
||
40 | 7 | if (is_array($recipients)) { |
|
41 | 1 | $recipients = implode(',', $recipients); |
|
42 | } |
||
43 | |||
44 | 7 | $this->recipients = $recipients; |
|
45 | |||
46 | 7 | return $this; |
|
47 | } |
||
48 | |||
49 | 2 | public function setReference($reference) |
|
55 | |||
56 | public function setDatacoding($datacoding) |
||
57 | { |
||
62 | |||
63 | public function toJson() |
||
67 | } |
||
68 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: