1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File containing the {@see Mailcode_Factory_CommandSets_Set_ElseIf} class. |
4
|
|
|
* |
5
|
|
|
* @package Mailcode |
6
|
|
|
* @subpackage Factory |
7
|
|
|
* @see Mailcode_Factory_CommandSets_Set_ElseIf |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Mailcode; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Factory utility used to create commands. |
16
|
|
|
* |
17
|
|
|
* @package Mailcode |
18
|
|
|
* @subpackage Factory |
19
|
|
|
* @author Sebastian Mordziol <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class Mailcode_Factory_CommandSets_Set_ElseIf extends Mailcode_Factory_CommandSets_IfBase |
22
|
|
|
{ |
23
|
|
|
public function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf |
24
|
|
|
{ |
25
|
|
|
$command = $this->instantiator->buildIf('ElseIf', $condition, $type); |
26
|
|
|
|
27
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf) |
28
|
|
|
{ |
29
|
|
|
return $command; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIf', $command); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function var(string $variable, string $operand, string $value, bool $quoteValue=false, bool $insensitive=false) : Mailcode_Commands_Command_ElseIf_Variable |
36
|
|
|
{ |
37
|
|
|
$command = $this->instantiator->buildIfVar('ElseIf', $variable, $operand, $value, $quoteValue, $insensitive); |
38
|
|
|
|
39
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
40
|
|
|
{ |
41
|
|
|
return $command; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfVariable', $command); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function varString(string $variable, string $operand, string $value, bool $insensitive=false) : Mailcode_Commands_Command_ElseIf_Variable |
48
|
|
|
{ |
49
|
|
|
$command = $this->instantiator->buildIfVar('ElseIf', $variable, $operand, $value, true, $insensitive); |
50
|
|
|
|
51
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
52
|
|
|
{ |
53
|
|
|
return $command; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfVarString', $command); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function varEquals(string $variable, string $value, bool $quoteValue=false, bool $insensitive=false) : Mailcode_Commands_Command_ElseIf_Variable |
60
|
|
|
{ |
61
|
|
|
$command = $this->instantiator->buildIfVar('ElseIf', $variable, '==', $value, $quoteValue, $insensitive); |
62
|
|
|
|
63
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
64
|
|
|
{ |
65
|
|
|
return $command; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfVarEquals', $command); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function varEqualsString(string $variable, string $value, bool $insensitive=false) : Mailcode_Commands_Command_ElseIf_Variable |
72
|
|
|
{ |
73
|
|
|
$command = $this->instantiator->buildIfVar('ElseIf', $variable, '==', $value, true, $insensitive); |
74
|
|
|
|
75
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
76
|
|
|
{ |
77
|
|
|
return $command; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfVarEqualsString', $command); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function varEqualsNumber(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_EqualsNumber |
84
|
|
|
{ |
85
|
|
|
$command = $this->instantiator->buildIfEquals('ElseIf', $variable, $value); |
86
|
|
|
|
87
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_EqualsNumber) |
88
|
|
|
{ |
89
|
|
|
return $command; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
throw $this->instantiator->exceptionUnexpectedType('IfEqualsNumber', $command); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function varNotEquals(string $variable, string $value, bool $quoteValue=false, bool $insensitive=false) : Mailcode_Commands_Command_ElseIf_Variable |
96
|
|
|
{ |
97
|
|
|
$command = $this->instantiator->buildIfVar('ElseIf', $variable, '!=', $value, $quoteValue, $insensitive); |
98
|
|
|
|
99
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
100
|
|
|
{ |
101
|
|
|
return $command; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfVarNotEquals', $command); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function varNotEqualsString(string $variable, string $value, bool $insensitive=false) : Mailcode_Commands_Command_ElseIf_Variable |
108
|
|
|
{ |
109
|
|
|
$command = $this->instantiator->buildIfVar('ElseIf', $variable, '!=', $value, true, $insensitive); |
110
|
|
|
|
111
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
112
|
|
|
{ |
113
|
|
|
return $command; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfVarNotEqualsString', $command); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param string $variable |
121
|
|
|
* @param string[] $searchTerms |
122
|
|
|
* @param bool $caseInsensitive |
123
|
|
|
* @return Mailcode_Commands_Command_ElseIf_Contains |
124
|
|
|
* @throws Mailcode_Factory_Exception |
125
|
|
|
*/ |
126
|
|
|
public function contains(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains |
127
|
|
|
{ |
128
|
|
|
$command = $this->instantiator->buildIfContains('ElseIf', $variable, $searchTerms, $caseInsensitive); |
129
|
|
|
|
130
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
131
|
|
|
{ |
132
|
|
|
return $command; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfContains', $command); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param string $variable |
140
|
|
|
* @param string[] $searchTerms |
141
|
|
|
* @param bool $caseInsensitive |
142
|
|
|
* @return Mailcode_Commands_Command_ElseIf_NotContains |
143
|
|
|
* @throws Mailcode_Factory_Exception |
144
|
|
|
*/ |
145
|
|
|
public function notContains(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_NotContains |
146
|
|
|
{ |
147
|
|
|
$command = $this->instantiator->buildIfNotContains('ElseIf', $variable, $searchTerms, $caseInsensitive); |
148
|
|
|
|
149
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_NotContains) |
150
|
|
|
{ |
151
|
|
|
return $command; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfNotContains', $command); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param string $variable |
159
|
|
|
* @param string[] $searchTerms |
160
|
|
|
* @param bool $caseInsensitive |
161
|
|
|
* @param bool $regexEnabled |
162
|
|
|
* @return Mailcode_Commands_Command_ElseIf_ListContains |
163
|
|
|
* @throws Mailcode_Factory_Exception |
164
|
|
|
*/ |
165
|
|
|
public function listContains(string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_Command_ElseIf_ListContains |
166
|
|
|
{ |
167
|
|
|
$command = $this->instantiator->buildIfListContains('ElseIf', $variable, $searchTerms, $caseInsensitive, $regexEnabled); |
168
|
|
|
|
169
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_ListContains) |
170
|
|
|
{ |
171
|
|
|
return $command; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfListContains', $command); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param string $variable |
179
|
|
|
* @param string[] $searchTerms |
180
|
|
|
* @param bool $caseInsensitive |
181
|
|
|
* @return Mailcode_Commands_Command_ElseIf_ListEquals |
182
|
|
|
* @throws Mailcode_Factory_Exception |
183
|
|
|
*/ |
184
|
|
|
public function listEquals(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_ListEquals |
185
|
|
|
{ |
186
|
|
|
$command = $this->instantiator->buildIfListContains('ElseIf', $variable, $searchTerms, $caseInsensitive, false, 'list-equals'); |
187
|
|
|
|
188
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_ListEquals) |
189
|
|
|
{ |
190
|
|
|
return $command; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfListEquals', $command); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param string $variable |
198
|
|
|
* @param string[] $searchTerms |
199
|
|
|
* @param bool $caseInsensitive |
200
|
|
|
* @param bool $regexEnabled |
201
|
|
|
* @return Mailcode_Commands_Command_ElseIf_ListNotContains |
202
|
|
|
* @throws Mailcode_Factory_Exception |
203
|
|
|
*/ |
204
|
|
|
public function listNotContains(string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_Command_ElseIf_ListNotContains |
205
|
|
|
{ |
206
|
|
|
$command = $this->instantiator->buildIfListNotContains('ElseIf', $variable, $searchTerms, $caseInsensitive, $regexEnabled); |
207
|
|
|
|
208
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_ListNotContains) |
209
|
|
|
{ |
210
|
|
|
return $command; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfListNotContains', $command); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @param string $variable |
218
|
|
|
* @param string[] $searchTerms |
219
|
|
|
* @param bool $caseInsensitive |
220
|
|
|
* @param bool $regexEnabled |
221
|
|
|
* @return Mailcode_Commands_Command_ElseIf_ListBeginsWith |
222
|
|
|
* @throws Mailcode_Factory_Exception |
223
|
|
|
*/ |
224
|
|
|
public function listBeginsWith(string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_Command_ElseIf_ListBeginsWith |
225
|
|
|
{ |
226
|
|
|
$command = $this->instantiator->buildIfListContains('ElseIf', $variable, $searchTerms, $caseInsensitive, $regexEnabled, 'list-begins-with'); |
227
|
|
|
|
228
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_ListBeginsWith) |
229
|
|
|
{ |
230
|
|
|
return $command; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfListBeginsWith', $command); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @param string $variable |
238
|
|
|
* @param string[] $searchTerms |
239
|
|
|
* @param bool $caseInsensitive |
240
|
|
|
* @param bool $regexEnabled |
241
|
|
|
* @return Mailcode_Commands_Command_ElseIf_ListEndsWith |
242
|
|
|
* @throws Mailcode_Factory_Exception |
243
|
|
|
*/ |
244
|
|
|
public function listEndsWith(string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_Command_ElseIf_ListEndsWith |
245
|
|
|
{ |
246
|
|
|
$command = $this->instantiator->buildIfListContains('ElseIf', $variable, $searchTerms, $caseInsensitive, $regexEnabled, 'list-ends-with'); |
247
|
|
|
|
248
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_ListEndsWith) |
249
|
|
|
{ |
250
|
|
|
return $command; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfListEndsWith', $command); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
public function beginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_BeginsWith |
257
|
|
|
{ |
258
|
|
|
$command = $this->instantiator->buildIfBeginsWith('ElseIf', $variable, $search, $caseInsensitive); |
259
|
|
|
|
260
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_BeginsWith) |
261
|
|
|
{ |
262
|
|
|
return $command; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfBeginsWith', $command); |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
public function endsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_EndsWith |
269
|
|
|
{ |
270
|
|
|
$command = $this->instantiator->buildIfEndsWith('ElseIf', $variable, $search, $caseInsensitive); |
271
|
|
|
|
272
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_EndsWith) |
273
|
|
|
{ |
274
|
|
|
return $command; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfEndsWith', $command); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
public function empty(string $variable) : Mailcode_Commands_Command_ElseIf_Empty |
281
|
|
|
{ |
282
|
|
|
$command = $this->instantiator->buildIfEmpty('ElseIf', $variable); |
283
|
|
|
|
284
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Empty) |
285
|
|
|
{ |
286
|
|
|
return $command; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfEmpty', $command); |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
public function notEmpty(string $variable) : Mailcode_Commands_Command_ElseIf_NotEmpty |
293
|
|
|
{ |
294
|
|
|
$command = $this->instantiator->buildIfNotEmpty('ElseIf', $variable); |
295
|
|
|
|
296
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_NotEmpty) |
297
|
|
|
{ |
298
|
|
|
return $command; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfNotEmpty', $command); |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
public function biggerThan(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_BiggerThan |
305
|
|
|
{ |
306
|
|
|
$command = $this->instantiator->buildIfBiggerThan('ElseIf', $variable, $value); |
307
|
|
|
|
308
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_BiggerThan) |
309
|
|
|
{ |
310
|
|
|
return $command; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfBiggerThan', $command); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
public function smallerThan(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_SmallerThan |
317
|
|
|
{ |
318
|
|
|
$command = $this->instantiator->buildIfSmallerThan('ElseIf', $variable, $value); |
319
|
|
|
|
320
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_SmallerThan) |
321
|
|
|
{ |
322
|
|
|
return $command; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfSmallerThan', $command); |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
public function equalsNumber(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_EqualsNumber |
329
|
|
|
{ |
330
|
|
|
$command = $this->instantiator->buildIfEquals('ElseIf', $variable, $value); |
331
|
|
|
|
332
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_EqualsNumber) |
333
|
|
|
{ |
334
|
|
|
return $command; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfEqualsNumber', $command); |
338
|
|
|
} |
339
|
|
|
} |
340
|
|
|
|