Passed
Push — master ( 77f2a3...0c35c3 )
by Sebastian
03:02
created

ifNotContains()   A

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 3
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 Utilities
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 Utilities
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 ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
36
    {
37
        $command = $this->instantiator->buildIfVar('If', $variable, $operand, $value, $quoteValue);
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 ifVarString(string $variable, string $operand, string $value) : Mailcode_Commands_Command_If_Variable
48
    {
49
        $command = $this->instantiator->buildIfVar('If', $variable, $operand, $value, true);
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 ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
60
    {
61
        $command = $this->instantiator->buildIfVar('If', $variable, '==', $value, $quoteValue);
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 ifVarEqualsString(string $variable, string $value) : Mailcode_Commands_Command_If
72
    {
73
        $command = $this->instantiator->buildIfVar('If', $variable, '==', $value, true);
74
        
75
        if($command instanceof Mailcode_Commands_Command_If_Variable)
76
        {
77
            return $command;
78
        }
79
        
80
        throw $this->instantiator->exceptionUnexpectedType('IfarEqualsString', $command);
81
    }
82
    
83
    public function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
84
    {
85
        $command = $this->instantiator->buildIfVar('If', $variable, '!=', $value, $quoteValue);
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 ifVarNotEqualsString(string $variable, string $value) : Mailcode_Commands_Command_If_Variable
96
    {
97
        $command = $this->instantiator->buildIfVar('If', $variable, '!=', $value, true);
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 ifEmpty(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 ifNotEmpty(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 ifContains(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 ifNotContains(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains
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
    public function ifBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_BeginsWith
170
    {
171
        $command = $this->instantiator->buildIfBeginsWith('If', $variable, $search, $caseInsensitive);
172
        
173
        if($command instanceof Mailcode_Commands_Command_If_BeginsWith)
174
        {
175
            return $command;
176
        }
177
        
178
        throw $this->instantiator->exceptionUnexpectedType('IfBeginsWith', $command);
179
    }
180
    
181
    public function ifEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_EndsWith
182
    {
183
        $command = $this->instantiator->buildIfEndsWith('If', $variable, $search, $caseInsensitive);
184
        
185
        if($command instanceof Mailcode_Commands_Command_If_EndsWith)
186
        {
187
            return $command;
188
        }
189
        
190
        throw $this->instantiator->exceptionUnexpectedType('IfEndsWith', $command);
191
    }
192
193
    public function ifBiggerThan(string $variable, string $value) : Mailcode_Commands_Command_If_BiggerThan
194
    {
195
        $command = $this->instantiator->buildIfBiggerThan('If', $variable, $value);
196
197
        if($command instanceof Mailcode_Commands_Command_If_BiggerThan)
198
        {
199
            return $command;
200
        }
201
202
        throw $this->instantiator->exceptionUnexpectedType('IfBiggerThan', $command);
203
    }
204
205
    public function ifSmallerThan(string $variable, string $value) : Mailcode_Commands_Command_If_SmallerThan
206
    {
207
        $command = $this->instantiator->buildIfSmallerThan('If', $variable, $value);
208
209
        if($command instanceof Mailcode_Commands_Command_If_SmallerThan)
210
        {
211
            return $command;
212
        }
213
214
        throw $this->instantiator->exceptionUnexpectedType('IfSmallerThan', $command);
215
    }
216
217
    public function ifVarEqualsNumber(string $variable, string $value) : Mailcode_Commands_Command_If_EqualsNumber
218
    {
219
        $command = $this->instantiator->buildIfEquals('If', $variable, $value);
220
221
        if($command instanceof Mailcode_Commands_Command_If_EqualsNumber)
222
        {
223
            return $command;
224
        }
225
226
        throw $this->instantiator->exceptionUnexpectedType('IfEqualsNumber', $command);
227
    }
228
}
229