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

elseIfNotContains()   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_CommandSets_Set_ElseIf} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Utilities
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 Utilities
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 elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
36
    {
37
        $command = $this->instantiator->buildIfVar('ElseIf', $variable, $operand, $value, $quoteValue);
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 elseIfVarString(string $variable, string $operand, string $value) : Mailcode_Commands_Command_ElseIf_Variable
48
    {
49
        $command = $this->instantiator->buildIfVar('ElseIf', $variable, $operand, $value, true);
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 elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
60
    {
61
        $command = $this->instantiator->buildIfVar('ElseIf', $variable, '==', $value, $quoteValue);
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 elseIfVarEqualsString(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_Variable
72
    {
73
        $command = $this->instantiator->buildIfVar('ElseIf', $variable, '==', $value, true);
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 elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
84
    {
85
        $command = $this->instantiator->buildIfVar('ElseIf', $variable, '!=', $value, $quoteValue);
86
        
87
        if($command instanceof Mailcode_Commands_Command_ElseIf_Variable)
88
        {
89
            return $command;
90
        }
91
        
92
        throw $this->instantiator->exceptionUnexpectedType('ElseIfVarNotEquals', $command);
93
    }
94
    
95
    public function elseIfVarNotEqualsString(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_Variable
96
    {
97
        $command = $this->instantiator->buildIfVar('ElseIf', $variable, '!=', $value, true);
98
        
99
        if($command instanceof Mailcode_Commands_Command_ElseIf_Variable)
100
        {
101
            return $command;
102
        }
103
        
104
        throw $this->instantiator->exceptionUnexpectedType('ElseIfVarNotEqualsString', $command);
105
    }
106
107
    /**
108
     * @param string $variable
109
     * @param string[] $searchTerms
110
     * @param bool $caseInsensitive
111
     * @return Mailcode_Commands_Command_ElseIf_Contains
112
     * @throws Mailcode_Factory_Exception
113
     */
114
    public function elseIfContains(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains
115
    {
116
        $command = $this->instantiator->buildIfContains('ElseIf', $variable, $searchTerms, $caseInsensitive);
117
        
118
        if($command instanceof Mailcode_Commands_Command_ElseIf_Contains)
119
        {
120
            return $command;
121
        }
122
        
123
        throw $this->instantiator->exceptionUnexpectedType('ElseIfContains', $command);
124
    }
125
126
    /**
127
     * @param string $variable
128
     * @param string[] $searchTerms
129
     * @param bool $caseInsensitive
130
     * @return Mailcode_Commands_Command_ElseIf_NotContains
131
     * @throws Mailcode_Factory_Exception
132
     */
133
    public function elseIfNotContains(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_NotContains
134
    {
135
        $command = $this->instantiator->buildIfNotContains('ElseIf', $variable, $searchTerms, $caseInsensitive);
136
137
        if($command instanceof Mailcode_Commands_Command_ElseIf_NotContains)
138
        {
139
            return $command;
140
        }
141
142
        throw $this->instantiator->exceptionUnexpectedType('ElseIfNotContains', $command);
143
    }
144
145
    public function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_BeginsWith
146
    {
147
        $command = $this->instantiator->buildIfBeginsWith('ElseIf', $variable, $search, $caseInsensitive);
148
        
149
        if($command instanceof Mailcode_Commands_Command_ElseIf_BeginsWith)
150
        {
151
            return $command;
152
        }
153
        
154
        throw $this->instantiator->exceptionUnexpectedType('ElseIfBeginsWith', $command);
155
    }
156
    
157
    public function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_EndsWith
158
    {
159
        $command = $this->instantiator->buildIfEndsWith('ElseIf', $variable, $search, $caseInsensitive);
160
        
161
        if($command instanceof Mailcode_Commands_Command_ElseIf_EndsWith)
162
        {
163
            return $command;
164
        }
165
        
166
        throw $this->instantiator->exceptionUnexpectedType('ElseIfEndsWith', $command);
167
    }
168
    
169
    public function elseIfEmpty(string $variable) : Mailcode_Commands_Command_ElseIf_Empty
170
    {
171
        $command = $this->instantiator->buildIfEmpty('ElseIf', $variable);
172
        
173
        if($command instanceof Mailcode_Commands_Command_ElseIf_Empty)
174
        {
175
            return $command;
176
        }
177
        
178
        throw $this->instantiator->exceptionUnexpectedType('ElseIfEmpty', $command);
179
    }
180
    
181
    public function elseIfNotEmpty(string $variable) : Mailcode_Commands_Command_ElseIf_NotEmpty
182
    {
183
        $command = $this->instantiator->buildIfNotEmpty('ElseIf', $variable);
184
        
185
        if($command instanceof Mailcode_Commands_Command_ElseIf_NotEmpty)
186
        {
187
            return $command;
188
        }
189
        
190
        throw $this->instantiator->exceptionUnexpectedType('ElseIfNotEmpty', $command);
191
    }
192
193
    public function elseIfBiggerThan(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_BiggerThan
194
    {
195
        $command = $this->instantiator->buildIfBiggerThan('ElseIf', $variable, $value);
196
197
        if($command instanceof Mailcode_Commands_Command_ElseIf_BiggerThan)
198
        {
199
            return $command;
200
        }
201
202
        throw $this->instantiator->exceptionUnexpectedType('ElseIfBiggerThan', $command);
203
    }
204
205
    public function elseIfSmallerThan(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_SmallerThan
206
    {
207
        $command = $this->instantiator->buildIfSmallerThan('ElseIf', $variable, $value);
208
209
        if($command instanceof Mailcode_Commands_Command_ElseIf_SmallerThan)
210
        {
211
            return $command;
212
        }
213
214
        throw $this->instantiator->exceptionUnexpectedType('ElseIfSmallerThan', $command);
215
    }
216
217
    public function elseIfVarEqualsNumber(string $variable, string $value) : Mailcode_Commands_Command_ElseIf_EqualsNumber
218
    {
219
        $command = $this->instantiator->buildIfEquals('ElseIf', $variable, $value);
220
221
        if($command instanceof Mailcode_Commands_Command_ElseIf_EqualsNumber)
222
        {
223
            return $command;
224
        }
225
226
        throw $this->instantiator->exceptionUnexpectedType('ElseIfEqualsNumber', $command);
227
    }
228
}
229