@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Mailcode_Factory_Instantiator |
22 | 22 | { |
23 | - public function buildIf(string $ifType, string $params, string $type='') : Mailcode_Commands_IfBase |
|
23 | + public function buildIf(string $ifType, string $params, string $type = '') : Mailcode_Commands_IfBase |
|
24 | 24 | { |
25 | 25 | $stringType = $type; |
26 | 26 | |
27 | - if(!empty($type)) |
|
27 | + if (!empty($type)) |
|
28 | 28 | { |
29 | 29 | $stringType = ' '.$type; |
30 | 30 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $this->checkCommand($command); |
45 | 45 | |
46 | - if($command instanceof Mailcode_Commands_IfBase) |
|
46 | + if ($command instanceof Mailcode_Commands_IfBase) |
|
47 | 47 | { |
48 | 48 | return $command; |
49 | 49 | } |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | throw $this->exceptionUnexpectedType('IfBase', $command); |
52 | 52 | } |
53 | 53 | |
54 | - public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_IfBase |
|
54 | + public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_IfBase |
|
55 | 55 | { |
56 | - if($quoteValue) |
|
56 | + if ($quoteValue) |
|
57 | 57 | { |
58 | 58 | $value = $this->quoteString($value); |
59 | 59 | } |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * @return Mailcode_Commands_IfBase |
87 | 87 | * @throws Mailcode_Factory_Exception |
88 | 88 | */ |
89 | - public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, string $containsType='contains') : Mailcode_Commands_IfBase |
|
89 | + public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, string $containsType = 'contains') : Mailcode_Commands_IfBase |
|
90 | 90 | { |
91 | 91 | $keyword = ' '; |
92 | 92 | |
93 | - if($caseInsensitive) |
|
93 | + if ($caseInsensitive) |
|
94 | 94 | { |
95 | 95 | $keyword = ' '.Mailcode_Commands_Keywords::TYPE_INSENSITIVE; |
96 | 96 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @return Mailcode_Commands_IfBase |
114 | 114 | * @throws Mailcode_Factory_Exception |
115 | 115 | */ |
116 | - public function buildIfNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
116 | + public function buildIfNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
117 | 117 | { |
118 | 118 | return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, 'not-contains'); |
119 | 119 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return Mailcode_Commands_IfBase |
128 | 128 | * @throws Mailcode_Factory_Exception |
129 | 129 | */ |
130 | - public function buildIfListContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, string $containsType='list-contains') : Mailcode_Commands_IfBase |
|
130 | + public function buildIfListContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, string $containsType = 'list-contains') : Mailcode_Commands_IfBase |
|
131 | 131 | { |
132 | 132 | return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, 'list-contains'); |
133 | 133 | } |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | * @return Mailcode_Commands_IfBase |
142 | 142 | * @throws Mailcode_Factory_Exception |
143 | 143 | */ |
144 | - public function buildIfListNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, string $containsType='list-contains') : Mailcode_Commands_IfBase |
|
144 | + public function buildIfListNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, string $containsType = 'list-contains') : Mailcode_Commands_IfBase |
|
145 | 145 | { |
146 | 146 | return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, 'list-not-contains'); |
147 | 147 | } |
148 | 148 | |
149 | - public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
149 | + public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
150 | 150 | { |
151 | 151 | return $this->buildIfSearch($ifType, 'begins-with', $variable, $search, $caseInsensitive); |
152 | 152 | } |
153 | 153 | |
154 | - public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
154 | + public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
155 | 155 | { |
156 | 156 | return $this->buildIfSearch($ifType, 'ends-with', $variable, $search, $caseInsensitive); |
157 | 157 | } |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
204 | - private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
204 | + private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
205 | 205 | { |
206 | 206 | $keyword = ' '; |
207 | 207 | |
208 | - if($caseInsensitive) |
|
208 | + if ($caseInsensitive) |
|
209 | 209 | { |
210 | 210 | $keyword = ' '.Mailcode_Commands_Keywords::TYPE_INSENSITIVE; |
211 | 211 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | public function checkCommand(Mailcode_Commands_Command $command) : void |
236 | 236 | { |
237 | - if($command->isValid()) |
|
237 | + if ($command->isValid()) |
|
238 | 238 | { |
239 | 239 | return; |
240 | 240 | } |
@@ -176,27 +176,27 @@ |
||
176 | 176 | * @return array<string,string> |
177 | 177 | * @throws Mailcode_Exception |
178 | 178 | */ |
179 | - private function parseVarName() : array |
|
180 | - { |
|
181 | - $tokens = explode('.', ltrim($this->variable->getFullName(), '$')); |
|
182 | - |
|
183 | - if(count($tokens) === 2) |
|
184 | - { |
|
185 | - return array( |
|
186 | - 'path' => $tokens[0], |
|
187 | - 'name' => $tokens[1] |
|
188 | - ); |
|
189 | - } |
|
190 | - |
|
191 | - throw new Mailcode_Exception( |
|
192 | - 'Invalid variable name for a list property.', |
|
193 | - sprintf( |
|
194 | - 'Exactly 2 parts are required, variable [%s] has [%s].', |
|
195 | - $this->variable->getFullName(), |
|
196 | - count($tokens) |
|
197 | - ), |
|
198 | - self::ERROR_INVALID_LIST_VARIABLE_NAME |
|
199 | - ); |
|
200 | - } |
|
179 | + private function parseVarName() : array |
|
180 | + { |
|
181 | + $tokens = explode('.', ltrim($this->variable->getFullName(), '$')); |
|
182 | + |
|
183 | + if(count($tokens) === 2) |
|
184 | + { |
|
185 | + return array( |
|
186 | + 'path' => $tokens[0], |
|
187 | + 'name' => $tokens[1] |
|
188 | + ); |
|
189 | + } |
|
190 | + |
|
191 | + throw new Mailcode_Exception( |
|
192 | + 'Invalid variable name for a list property.', |
|
193 | + sprintf( |
|
194 | + 'Exactly 2 parts are required, variable [%s] has [%s].', |
|
195 | + $this->variable->getFullName(), |
|
196 | + count($tokens) |
|
197 | + ), |
|
198 | + self::ERROR_INVALID_LIST_VARIABLE_NAME |
|
199 | + ); |
|
200 | + } |
|
201 | 201 | } |
202 | 202 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function getSign() : string |
71 | 71 | { |
72 | - if($this->isNotContains()) |
|
72 | + if ($this->isNotContains()) |
|
73 | 73 | { |
74 | 74 | return '!'; |
75 | 75 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function getConnector() |
88 | 88 | { |
89 | - if($this->isNotContains()) |
|
89 | + if ($this->isNotContains()) |
|
90 | 90 | { |
91 | 91 | return '&&'; |
92 | 92 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $parts = array(); |
104 | 104 | |
105 | - foreach($this->searchTerms as $token) |
|
105 | + foreach ($this->searchTerms as $token) |
|
106 | 106 | { |
107 | 107 | $parts[] = $this->renderCommand($token); |
108 | 108 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | private function renderCommand(Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral $searchTerm) : string |
119 | 119 | { |
120 | - if($this->isList()) |
|
120 | + if ($this->isList()) |
|
121 | 121 | { |
122 | 122 | $command = $this->renderListCommand($searchTerm); |
123 | 123 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | private function renderRegex(Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral $searchTerm) : string |
159 | 159 | { |
160 | 160 | $opts = 's'; |
161 | - if($this->caseSensitive) |
|
161 | + if ($this->caseSensitive) |
|
162 | 162 | { |
163 | 163 | $opts = 'is'; |
164 | 164 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $tokens = explode('.', ltrim($this->variable->getFullName(), '$')); |
182 | 182 | |
183 | - if(count($tokens) === 2) |
|
183 | + if (count($tokens) === 2) |
|
184 | 184 | { |
185 | 185 | return array( |
186 | 186 | 'path' => $tokens[0], |
@@ -120,8 +120,7 @@ |
||
120 | 120 | if($this->isList()) |
121 | 121 | { |
122 | 122 | $command = $this->renderListCommand($searchTerm); |
123 | - } |
|
124 | - else |
|
123 | + } else |
|
125 | 124 | { |
126 | 125 | $command = $this->renderRegularCommand($searchTerm); |
127 | 126 | } |