Test Failed
Push — master ( f51294...9c5f94 )
by Sebastian
03:08
created
src/Mailcode/Commands/LogicKeywords.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,27 +30,27 @@  discard block
 block discarded – undo
30 30
     const VALIDATION_CANNOT_MIX_LOGIC_KEYWORDS = 60701;
31 31
     const VALIDATION_INVALID_SUB_COMMAND = 60702;
32 32
     
33
-   /**
34
-    * @var string
35
-    */
33
+    /**
34
+     * @var string
35
+     */
36 36
     private $paramsString;
37 37
     
38
-   /**
39
-    * @var string[]
40
-    */
38
+    /**
39
+     * @var string[]
40
+     */
41 41
     private $names = array(
42 42
         'and', 
43 43
         'or'
44 44
     );
45 45
     
46
-   /**
47
-    * @var Mailcode_Commands_LogicKeywords_Keyword[]
48
-    */
46
+    /**
47
+     * @var Mailcode_Commands_LogicKeywords_Keyword[]
48
+     */
49 49
     private $keywords = array();
50 50
     
51
-   /**
52
-    * @var string
53
-    */
51
+    /**
52
+     * @var string
53
+     */
54 54
     private $mainParams = '';
55 55
     
56 56
     public function __construct(Mailcode_Commands_Command $command, string $paramsString)
@@ -159,22 +159,22 @@  discard block
 block discarded – undo
159 159
         return $stack;
160 160
     }
161 161
     
162
-   /**
163
-    * Extracts the parameters string to use for the 
164
-    * original command itself, omitting all the logic
165
-    * keywords for the sub-commands.
166
-    * 
167
-    * @return string
168
-    */
162
+    /**
163
+     * Extracts the parameters string to use for the 
164
+     * original command itself, omitting all the logic
165
+     * keywords for the sub-commands.
166
+     * 
167
+     * @return string
168
+     */
169 169
     public function getMainParamsString() : string
170 170
     {
171 171
         return $this->mainParams;
172 172
     }
173 173
     
174
-   /**
175
-    * Retrieves the detected keyword names.
176
-    * @return string[]
177
-    */
174
+    /**
175
+     * Retrieves the detected keyword names.
176
+     * @return string[]
177
+     */
178 178
     public function getDetectedNames() : array
179 179
     {
180 180
         $names = array();
@@ -192,23 +192,23 @@  discard block
 block discarded – undo
192 192
         return $names;
193 193
     }
194 194
     
195
-   /**
196
-    * Retrieves all keywords that were detected in the
197
-    * command's parameters string, if any.
198
-    * 
199
-    * @return Mailcode_Commands_LogicKeywords_Keyword[]
200
-    */
195
+    /**
196
+     * Retrieves all keywords that were detected in the
197
+     * command's parameters string, if any.
198
+     * 
199
+     * @return Mailcode_Commands_LogicKeywords_Keyword[]
200
+     */
201 201
     public function getKeywords() : array
202 202
     {
203 203
         return $this->keywords;
204 204
     }
205 205
     
206
-   /**
207
-    * Detects any keyword statements in the parameters by keyword name.
208
-    * 
209
-    * @param string $name
210
-    * @return Mailcode_Commands_LogicKeywords_Keyword[]
211
-    */
206
+    /**
207
+     * Detects any keyword statements in the parameters by keyword name.
208
+     * 
209
+     * @param string $name
210
+     * @return Mailcode_Commands_LogicKeywords_Keyword[]
211
+     */
212 212
     private function detectKeywords(string $name) : array
213 213
     {
214 214
         $regex = sprintf('/%1$s\s+([a-z\-0-9]+):|%1$s:/x', $name);
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
     
71 71
     private function parse() : void
72 72
     {
73
-        foreach($this->names as $name)
73
+        foreach ($this->names as $name)
74 74
         {
75
-            if(!stristr($this->paramsString, $name))
75
+            if (!stristr($this->paramsString, $name))
76 76
             {
77 77
                 continue;
78 78
             }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         $names = $this->getDetectedNames();
90 90
         $amount = count($names);
91 91
         
92
-        if($amount > 1)
92
+        if ($amount > 1)
93 93
         {
94 94
             $this->makeError(
95 95
                 t(
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     
109 109
     private function splitParams() : void
110 110
     {
111
-        if(empty($this->keywords))
111
+        if (empty($this->keywords))
112 112
         {
113 113
             $this->mainParams = $this->paramsString;
114 114
             
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
         
118 118
         $params = $this->detectParameters();
119 119
         
120
-        foreach($this->keywords as $keyword)
120
+        foreach ($this->keywords as $keyword)
121 121
         {
122 122
             $kParams = array_shift($params);
123 123
             
124 124
             $keyword->setParamsString($kParams);
125 125
             
126
-            if(!$keyword->isValid())
126
+            if (!$keyword->isValid())
127 127
             {
128 128
                 $this->makeError(
129 129
                     t('Error #%1$s:', $keyword->getCode()).' '.$keyword->getErrorMessage(),
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
         $params = $this->paramsString;
141 141
         $stack = array();
142 142
         
143
-        foreach($this->keywords as $keyword)
143
+        foreach ($this->keywords as $keyword)
144 144
         {
145 145
             $search = $keyword->getMatchedString();
146 146
             $pos = strpos($params, $search);
147 147
             $length = strlen($search);
148 148
             
149 149
             $store = substr($params, 0, $pos);
150
-            $params = trim(substr($params, $pos+$length));
150
+            $params = trim(substr($params, $pos + $length));
151 151
             
152 152
             $stack[] = $store;
153 153
         }
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
     {
180 180
         $names = array();
181 181
         
182
-        foreach($this->keywords as $keyword)
182
+        foreach ($this->keywords as $keyword)
183 183
         {
184 184
             $name = $keyword->getName();
185 185
             
186
-            if(!in_array($name, $names))
186
+            if (!in_array($name, $names))
187 187
             {
188 188
                 $names[] = $name;
189 189
             }
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
         $matches = array();
217 217
         preg_match_all($regex, $this->paramsString, $matches, PREG_PATTERN_ORDER);
218 218
         
219
-        if(!isset($matches[0][0]) || empty($matches[0][0]))
219
+        if (!isset($matches[0][0]) || empty($matches[0][0]))
220 220
         {
221 221
             return array();
222 222
         }
223 223
         
224 224
         $amount = count($matches[0]);
225 225
         
226
-        for($i=0; $i < $amount; $i++)
226
+        for ($i = 0; $i < $amount; $i++)
227 227
         {
228 228
             $result[] = $this->createKeyword(
229 229
                 $name, 
@@ -240,22 +240,22 @@  discard block
 block discarded – undo
240 240
         return !empty($this->keywords);
241 241
     }
242 242
     
243
-    public function appendAND(string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword
243
+    public function appendAND(string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword
244 244
     {
245 245
         return $this->appendKeyword('and', $paramsString, $type);
246 246
     }
247 247
     
248
-    public function appendOR(string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword
248
+    public function appendOR(string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword
249 249
     {
250 250
         return $this->appendKeyword('or', $paramsString, $type);
251 251
     }
252 252
     
253
-    public function appendKeyword(string $name, string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword
253
+    public function appendKeyword(string $name, string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword
254 254
     {
255 255
         $keyword = $this->createKeyword($name, $type);
256 256
         $keyword->setParamsString($paramsString);
257 257
         
258
-        if(!$keyword->isValid())
258
+        if (!$keyword->isValid())
259 259
         {
260 260
             throw new Mailcode_Exception(
261 261
                 'Cannot append invalid logic keyword',
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
         return $keyword;
277 277
     }
278 278
     
279
-    private function createKeyword(string $name, string $type='', string $matchedString='') : Mailcode_Commands_LogicKeywords_Keyword
279
+    private function createKeyword(string $name, string $type = '', string $matchedString = '') : Mailcode_Commands_LogicKeywords_Keyword
280 280
     {
281
-        if(empty($matchedString))
281
+        if (empty($matchedString))
282 282
         {
283 283
             $matchedString = $name;
284 284
             
285
-            if(!empty($type))
285
+            if (!empty($type))
286 286
             {
287 287
                 $matchedString .= ' '.$type;
288 288
             }
Please login to merge, or discard this patch.