Mailcode_Factory_CommandSets_Set_If::smallerThan()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Factory} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Factory
7
 * @see Mailcode_Factory
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_If extends Mailcode_Factory_CommandSets_IfBase
22
{
23
    public function if(string $condition, string $type='') : Mailcode_Commands_Command_If
24
    {
25
        $command = $this->instantiator->buildIf('If', $condition, $type);
26
        
27
        if($command instanceof Mailcode_Commands_Command_If)
28
        {
29
            return $command;
30
        }
31
        
32
        throw $this->instantiator->exceptionUnexpectedType('If', $command);
33
    }
34
    
35
    public function var(string $variable, string $operand, string $value, bool $quoteValue=false, bool $insensitive=false) : Mailcode_Commands_Command_If_Variable
36
    {
37
        $command = $this->instantiator->buildIfVar('If', $variable, $operand, $value, $quoteValue, $insensitive);
38
        
39
        if($command instanceof Mailcode_Commands_Command_If_Variable)
40
        {
41
            return $command;
42
        }
43
        
44
        throw $this->instantiator->exceptionUnexpectedType('IfVar', $command);
45
    }
46
    
47
    public function varString(string $variable, string $operand, string $value, bool $insensitive=false) : Mailcode_Commands_Command_If_Variable
48
    {
49
        $command = $this->instantiator->buildIfVar('If', $variable, $operand, $value, true, $insensitive);
50
        
51
        if($command instanceof Mailcode_Commands_Command_If_Variable)
52
        {
53
            return $command;
54
        }
55
        
56
        throw $this->instantiator->exceptionUnexpectedType('IfVarString', $command);
57
    }
58
    
59
    public function varEquals(string $variable, string $value, bool $quoteValue=false, bool $insensitive=false) : Mailcode_Commands_Command_If_Variable
60
    {
61
        $command = $this->instantiator->buildIfVar('If', $variable, '==', $value, $quoteValue, $insensitive);
62
        
63
        if($command instanceof Mailcode_Commands_Command_If_Variable)
64
        {
65
            return $command;
66
        }
67
        
68
        throw $this->instantiator->exceptionUnexpectedType('IfVarEquals', $command);
69
    }
70
    
71
    public function varEqualsString(string $variable, string $value, bool $insensitive=false) : Mailcode_Commands_Command_If
72
    {
73
        $command = $this->instantiator->buildIfVar('If', $variable, '==', $value, true, $insensitive);
74
        
75
        if($command instanceof Mailcode_Commands_Command_If_Variable)
76
        {
77
            return $command;
78
        }
79
        
80
        throw $this->instantiator->exceptionUnexpectedType('IfVarEqualsString', $command);
81
    }
82
    
83
    public function varNotEquals(string $variable, string $value, bool $quoteValue=false, bool $insensitive=false) : Mailcode_Commands_Command_If_Variable
84
    {
85
        $command = $this->instantiator->buildIfVar('If', $variable, '!=', $value, $quoteValue, $insensitive);
86
        
87
        if($command instanceof Mailcode_Commands_Command_If_Variable)
88
        {
89
            return $command;
90
        }
91
        
92
        throw $this->instantiator->exceptionUnexpectedType('IfVarNotEquals', $command);
93
    }
94
    
95
    public function varNotEqualsString(string $variable, string $value, bool $insensitive=false) : Mailcode_Commands_Command_If_Variable
96
    {
97
        $command = $this->instantiator->buildIfVar('If', $variable, '!=', $value, true, $insensitive);
98
        
99
        if($command instanceof Mailcode_Commands_Command_If_Variable)
100
        {
101
            return $command;
102
        }
103
        
104
        throw $this->instantiator->exceptionUnexpectedType('IfVarNotEqualsString', $command);
105
    }
106
    
107
    public function empty(string $variable) : Mailcode_Commands_Command_If_Empty
108
    {
109
        $command = $this->instantiator->buildIfEmpty('If', $variable);
110
        
111
        if($command instanceof Mailcode_Commands_Command_If_Empty)
112
        {
113
            return $command;
114
        }
115
        
116
        throw $this->instantiator->exceptionUnexpectedType('IfEmpty', $command);
117
    }
118
    
119
    public function notEmpty(string $variable) : Mailcode_Commands_Command_If_NotEmpty
120
    {
121
        $command = $this->instantiator->buildIfNotEmpty('If', $variable);
122
        
123
        if($command instanceof Mailcode_Commands_Command_If_NotEmpty)
124
        {
125
            return $command;
126
        }
127
        
128
        throw $this->instantiator->exceptionUnexpectedType('IfNotEmpty', $command);
129
    }
130
131
    /**
132
     * @param string $variable
133
     * @param string[] $searchTerms
134
     * @param bool $caseInsensitive
135
     * @return Mailcode_Commands_Command_If_Contains
136
     * @throws Mailcode_Factory_Exception
137
     */
138
    public function contains(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains
139
    {
140
        $command = $this->instantiator->buildIfContains('If', $variable, $searchTerms, $caseInsensitive);
141
        
142
        if($command instanceof Mailcode_Commands_Command_If_Contains)
143
        {
144
            return $command;
145
        }
146
        
147
        throw $this->instantiator->exceptionUnexpectedType('IfContains', $command);
148
    }
149
150
    /**
151
     * @param string $variable
152
     * @param string[] $searchTerms
153
     * @param bool $caseInsensitive
154
     * @return Mailcode_Commands_Command_If_NotContains
155
     * @throws Mailcode_Factory_Exception
156
     */
157
    public function notContains(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_NotContains
158
    {
159
        $command = $this->instantiator->buildIfNotContains('If', $variable, $searchTerms, $caseInsensitive);
160
161
        if($command instanceof Mailcode_Commands_Command_If_NotContains)
162
        {
163
            return $command;
164
        }
165
166
        throw $this->instantiator->exceptionUnexpectedType('IfNotContains', $command);
167
    }
168
169
    /**
170
     * @param string $variable
171
     * @param string[] $searchTerms
172
     * @param bool $caseInsensitive
173
     * @param bool $regexEnabled
174
     * @return Mailcode_Commands_Command_If_ListContains
175
     * @throws Mailcode_Factory_Exception
176
     */
177
    public function listContains(string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_Command_If_ListContains
178
    {
179
        $command = $this->instantiator->buildIfListContains('If', $variable, $searchTerms, $caseInsensitive, $regexEnabled, 'list-contains');
180
181
        if($command instanceof Mailcode_Commands_Command_If_ListContains)
182
        {
183
            return $command;
184
        }
185
186
        throw $this->instantiator->exceptionUnexpectedType('IfListContains', $command);
187
    }
188
189
    /**
190
     * @param string $variable
191
     * @param string[] $searchTerms
192
     * @param bool $caseInsensitive
193
     * @return Mailcode_Commands_Command_If_ListEquals
194
     * @throws Mailcode_Factory_Exception
195
     */
196
    public function listEquals(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_ListEquals
197
    {
198
        $command = $this->instantiator->buildIfListContains('If', $variable, $searchTerms, $caseInsensitive, false, 'list-equals');
199
200
        if($command instanceof Mailcode_Commands_Command_If_ListEquals)
201
        {
202
            return $command;
203
        }
204
205
        throw $this->instantiator->exceptionUnexpectedType('IfListEquals', $command);
206
    }
207
208
    /**
209
     * @param string $variable
210
     * @param string[] $searchTerms
211
     * @param bool $caseInsensitive
212
     * @param bool $regexEnabled
213
     * @return Mailcode_Commands_Command_If_ListNotContains
214
     * @throws Mailcode_Factory_Exception
215
     */
216
    public function listNotContains(string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_Command_If_ListNotContains
217
    {
218
        $command = $this->instantiator->buildIfListNotContains('If', $variable, $searchTerms, $caseInsensitive, $regexEnabled);
219
220
        if($command instanceof Mailcode_Commands_Command_If_ListNotContains)
221
        {
222
            return $command;
223
        }
224
225
        throw $this->instantiator->exceptionUnexpectedType('IfNotContains', $command);
226
    }
227
228
    /**
229
     * @param string $variable
230
     * @param string[] $searchTerms
231
     * @param bool $caseInsensitive
232
     * @param bool $regexEnabled
233
     * @return Mailcode_Commands_Command_If_ListBeginsWith
234
     * @throws Mailcode_Factory_Exception
235
     */
236
    public function listBeginsWith(string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_Command_If_ListBeginsWith
237
    {
238
        $command = $this->instantiator->buildIfListContains('If', $variable, $searchTerms, $caseInsensitive, $regexEnabled,'list-begins-with');
239
240
        if($command instanceof Mailcode_Commands_Command_If_ListBeginsWith)
241
        {
242
            return $command;
243
        }
244
245
        throw $this->instantiator->exceptionUnexpectedType('IfListBeginsWith', $command);
246
    }
247
248
    /**
249
     * @param string $variable
250
     * @param string[] $searchTerms
251
     * @param bool $caseInsensitive
252
     * @param bool $regexEnabled
253
     * @return Mailcode_Commands_Command_If_ListEndsWith
254
     * @throws Mailcode_Factory_Exception
255
     */
256
    public function listEndsWith(string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_Command_If_ListEndsWith
257
    {
258
        $command = $this->instantiator->buildIfListContains('If', $variable, $searchTerms, $caseInsensitive, $regexEnabled,'list-ends-with');
259
260
        if($command instanceof Mailcode_Commands_Command_If_ListEndsWith)
261
        {
262
            return $command;
263
        }
264
265
        throw $this->instantiator->exceptionUnexpectedType('IfListEndsWith', $command);
266
    }
267
268
    public function beginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_BeginsWith
269
    {
270
        $command = $this->instantiator->buildIfBeginsWith('If', $variable, $search, $caseInsensitive);
271
        
272
        if($command instanceof Mailcode_Commands_Command_If_BeginsWith)
273
        {
274
            return $command;
275
        }
276
        
277
        throw $this->instantiator->exceptionUnexpectedType('IfBeginsWith', $command);
278
    }
279
    
280
    public function endsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_EndsWith
281
    {
282
        $command = $this->instantiator->buildIfEndsWith('If', $variable, $search, $caseInsensitive);
283
        
284
        if($command instanceof Mailcode_Commands_Command_If_EndsWith)
285
        {
286
            return $command;
287
        }
288
        
289
        throw $this->instantiator->exceptionUnexpectedType('IfEndsWith', $command);
290
    }
291
292
    public function biggerThan(string $variable, string $value) : Mailcode_Commands_Command_If_BiggerThan
293
    {
294
        $command = $this->instantiator->buildIfBiggerThan('If', $variable, $value);
295
296
        if($command instanceof Mailcode_Commands_Command_If_BiggerThan)
297
        {
298
            return $command;
299
        }
300
301
        throw $this->instantiator->exceptionUnexpectedType('IfBiggerThan', $command);
302
    }
303
304
    public function smallerThan(string $variable, string $value) : Mailcode_Commands_Command_If_SmallerThan
305
    {
306
        $command = $this->instantiator->buildIfSmallerThan('If', $variable, $value);
307
308
        if($command instanceof Mailcode_Commands_Command_If_SmallerThan)
309
        {
310
            return $command;
311
        }
312
313
        throw $this->instantiator->exceptionUnexpectedType('IfSmallerThan', $command);
314
    }
315
316
    public function varEqualsNumber(string $variable, string $value) : Mailcode_Commands_Command_If_EqualsNumber
317
    {
318
        $command = $this->instantiator->buildIfEquals('If', $variable, $value);
319
320
        if($command instanceof Mailcode_Commands_Command_If_EqualsNumber)
321
        {
322
            return $command;
323
        }
324
325
        throw $this->instantiator->exceptionUnexpectedType('IfEqualsNumber', $command);
326
    }
327
}
328