|
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
|
|
|
public function elseIfContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains |
|
108
|
|
|
{ |
|
109
|
|
|
$command = $this->instantiator->buildIfContains('ElseIf', $variable, $search, $caseInsensitive); |
|
110
|
|
|
|
|
111
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
112
|
|
|
{ |
|
113
|
|
|
return $command; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfContains', $command); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function elseIfEmpty(string $variable) : Mailcode_Commands_Command_ElseIf_Empty |
|
120
|
|
|
{ |
|
121
|
|
|
$command = $this->instantiator->buildIfEmpty('ElseIf', $variable); |
|
122
|
|
|
|
|
123
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_Empty) |
|
124
|
|
|
{ |
|
125
|
|
|
return $command; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfEmpty', $command); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function elseIfNotEmpty(string $variable) : Mailcode_Commands_Command_ElseIf_NotEmpty |
|
132
|
|
|
{ |
|
133
|
|
|
$command = $this->instantiator->buildIfNotEmpty('ElseIf', $variable); |
|
134
|
|
|
|
|
135
|
|
|
if($command instanceof Mailcode_Commands_Command_ElseIf_NotEmpty) |
|
136
|
|
|
{ |
|
137
|
|
|
return $command; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
throw $this->instantiator->exceptionUnexpectedType('ElseIfNotEmpty', $command); |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|