1 | <?php |
||
15 | final class Message extends Swift_Message |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $campaignId; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $perRecipientTags; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | private $metadata; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $perRecipientMetadata; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | private $substitutionData; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | private $perRecipientSubstitutionData; |
||
46 | |||
47 | /** |
||
48 | * @var array |
||
49 | */ |
||
50 | private $options; |
||
51 | |||
52 | /** |
||
53 | * Create a new Message. |
||
54 | * |
||
55 | * @param string $subject |
||
56 | * @param string $body |
||
57 | * @param string $contentType |
||
58 | * @param string $charset |
||
59 | * |
||
60 | * @return $this |
||
61 | */ |
||
62 | 30 | public static function newInstance($subject = null, $body = null, $contentType = null, $charset = null) |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 69 | public function __construct($subject = null, $body = null, $contentType = null, $charset = null) |
|
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | 27 | public function getCampaignId() |
|
94 | |||
95 | /** |
||
96 | * @param string $campaignId |
||
97 | * |
||
98 | * @return Message |
||
99 | */ |
||
100 | 6 | public function setCampaignId($campaignId) |
|
106 | |||
107 | /** |
||
108 | * @return array |
||
109 | */ |
||
110 | 27 | public function getPerRecipientTags() |
|
114 | |||
115 | /** |
||
116 | * @param string $recipient |
||
117 | * @param array $tags |
||
118 | * |
||
119 | * @return Message |
||
120 | */ |
||
121 | 6 | public function setPerRecipientTags($recipient, array $tags) |
|
127 | |||
128 | /** |
||
129 | * @return array |
||
130 | */ |
||
131 | 27 | public function getMetadata() |
|
135 | |||
136 | /** |
||
137 | * @param array $metadata |
||
138 | * |
||
139 | * @return Message |
||
140 | */ |
||
141 | 12 | public function setMetadata(array $metadata) |
|
147 | |||
148 | /** |
||
149 | * @return array |
||
150 | */ |
||
151 | 27 | public function getPerRecipientMetadata() |
|
155 | |||
156 | /** |
||
157 | * @param string $recipient |
||
158 | * @param array $metadata |
||
159 | * |
||
160 | * @return Message |
||
161 | */ |
||
162 | 12 | public function setPerRecipientMetadata($recipient, array $metadata) |
|
168 | |||
169 | /** |
||
170 | * @return array |
||
171 | */ |
||
172 | 27 | public function getSubstitutionData() |
|
176 | |||
177 | /** |
||
178 | * @param array $substitutionData |
||
179 | * |
||
180 | * @return Message |
||
181 | */ |
||
182 | 6 | public function setSubstitutionData(array $substitutionData) |
|
188 | |||
189 | /** |
||
190 | * @return array |
||
191 | */ |
||
192 | 27 | public function getPerRecipientSubstitutionData() |
|
196 | |||
197 | /** |
||
198 | * @param string $recipient |
||
199 | * @param array $substitutionData |
||
200 | * |
||
201 | * @return Message |
||
202 | */ |
||
203 | 6 | public function setPerRecipientSubstitutionData($recipient, array $substitutionData) |
|
209 | |||
210 | /** |
||
211 | * @return array |
||
212 | */ |
||
213 | 27 | public function getOptions() |
|
217 | |||
218 | /** |
||
219 | * @param array $options |
||
220 | * |
||
221 | * @return Message |
||
222 | */ |
||
223 | 9 | public function setOptions(array $options) |
|
229 | |||
230 | /** |
||
231 | * @param array $tags |
||
232 | * |
||
233 | * @return array |
||
234 | */ |
||
235 | 6 | private function sanitizeTags(array $tags) |
|
245 | |||
246 | /** |
||
247 | * @param array $metadata |
||
248 | * |
||
249 | * @return array |
||
250 | */ |
||
251 | 18 | private function sanitizeMetadata(array $metadata) |
|
264 | |||
265 | /** |
||
266 | * @param array $substitutionData |
||
267 | * |
||
268 | * @return array |
||
269 | */ |
||
270 | 6 | private function sanitizeubstitutionData(array $substitutionData) |
|
280 | |||
281 | /** |
||
282 | * @param array $options |
||
283 | * |
||
284 | * @return array |
||
285 | * @throws Exception |
||
286 | */ |
||
287 | 9 | private function sanitizeOptions(array $options) |
|
311 | } |
||
312 |
PHP has two types of connecting operators (logical operators, and boolean operators):
and
&&
or
||
The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&
, or||
.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
die
introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrow
at this point:These limitations lead to logical operators rarely being of use in current PHP code.