Passed
Push — master ( d4ccbb...333908 )
by Sebastian
03:27
created
src/Localization/Parser/Language.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     */
83 83
     public function getID() : string
84 84
     {
85
-        if(!isset($this->id)) {
85
+        if (!isset($this->id)) {
86 86
             $this->id = str_replace(Localization_Parser_Language::class.'_', '', get_class($this));
87 87
         }
88 88
         
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     */
108 108
     public function parseFile(string $path) : void
109 109
     {
110
-        if(!file_exists($path)) 
110
+        if (!file_exists($path)) 
111 111
         {
112 112
             throw new Localization_Exception(
113 113
                 sprintf('Source code file [%s] not found', basename($path)),
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
         $this->tokens = $this->getTokens();
161 161
         $this->totalTokens = count($this->tokens);
162 162
         
163
-        for($i = 0; $i < $this->totalTokens; $i++)
163
+        for ($i = 0; $i < $this->totalTokens; $i++)
164 164
         {
165 165
             $token = $this->createToken($this->tokens[$i]);
166 166
             
167
-            if($token->isTranslationFunction()) {
168
-                $this->parseToken($i+1, $token);
167
+            if ($token->isTranslationFunction()) {
168
+                $this->parseToken($i + 1, $token);
169 169
             }
170 170
         }
171 171
     }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         return $this->texts;
179 179
     }
180 180
     
181
-    protected function addResult(string $text, int $line=0, string $explanation='') : void
181
+    protected function addResult(string $text, int $line = 0, string $explanation = '') : void
182 182
     {
183 183
         $this->log(sprintf('Line [%1$s] | Found string [%2$s]', $line, $text));
184 184
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     * @param Localization_Parser_Token|NULL $parentToken
245 245
     * @return Localization_Parser_Token
246 246
     */
247
-    protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token
247
+    protected function createToken($definition, Localization_Parser_Token $parentToken = null) : Localization_Parser_Token
248 248
     {
249 249
         $class = Localization_Parser_Token::class.'_'.$this->getID();
250 250
         
@@ -264,48 +264,48 @@  discard block
 block discarded – undo
264 264
         $open = false;
265 265
         $explanation = '';
266 266
         
267
-        for($i = $number; $i < $max; $i++)
267
+        for ($i = $number; $i < $max; $i++)
268 268
         {
269
-            if(!isset($this->tokens[$i])) {
269
+            if (!isset($this->tokens[$i])) {
270 270
                 break;
271 271
             }
272 272
             
273 273
             $subToken = $this->createToken($this->tokens[$i], $token);
274 274
             
275
-            if(!$open && $subToken->isOpeningFuncParams())
275
+            if (!$open && $subToken->isOpeningFuncParams())
276 276
             {
277 277
                 $open = true;
278 278
                 continue;
279 279
             }
280 280
             
281
-            if($open && $subToken->isClosingFuncParams()) {
281
+            if ($open && $subToken->isClosingFuncParams()) {
282 282
                 break;
283 283
             }
284 284
             
285 285
             // additional parameters in the translation function, we don't want to capture these now.
286
-            if($open && $subToken->isArgumentSeparator())
286
+            if ($open && $subToken->isArgumentSeparator())
287 287
             {
288
-                if($token->isExplanationFunction()) {
289
-                    $leftover = array_slice($this->tokens, $i+1);
288
+                if ($token->isExplanationFunction()) {
289
+                    $leftover = array_slice($this->tokens, $i + 1);
290 290
                     $explanation = $this->parseExplanation($token, $leftover);
291 291
                 }
292 292
                 break;
293 293
             }
294 294
             
295
-            if($open && $subToken->isEncapsedString())
295
+            if ($open && $subToken->isEncapsedString())
296 296
             {
297 297
                 $textParts[] = $this->trimText(strval($subToken->getValue()));
298 298
                 continue;
299 299
             }
300 300
             
301
-            if($open && $subToken->isVariableOrFunction()) {
301
+            if ($open && $subToken->isVariableOrFunction()) {
302 302
                 $textParts = null;
303 303
                 $this->addWarning($subToken, t('Variables or functions are not supported in translation functions.'));
304 304
                 break;
305 305
             }
306 306
         }
307 307
         
308
-        if(empty($textParts)) {
308
+        if (empty($textParts)) {
309 309
             return;
310 310
         }
311 311
         
@@ -319,38 +319,38 @@  discard block
 block discarded – undo
319 319
         $textParts = array();
320 320
         $max = 200;
321 321
 
322
-        for($i = 0; $i < $max; $i++)
322
+        for ($i = 0; $i < $max; $i++)
323 323
         {
324
-            if(!isset($tokens[$i])) {
324
+            if (!isset($tokens[$i])) {
325 325
                 break;
326 326
             }
327 327
 
328 328
             $subToken = $this->createToken($tokens[$i], $token);
329 329
 
330
-            if($subToken->isClosingFuncParams()) {
330
+            if ($subToken->isClosingFuncParams()) {
331 331
                 break;
332 332
             }
333 333
 
334 334
             // additional parameters in the translation function, we don't want to capture these now.
335
-            if($subToken->isArgumentSeparator())
335
+            if ($subToken->isArgumentSeparator())
336 336
             {
337 337
                 break;
338 338
             }
339 339
 
340
-            if($subToken->isEncapsedString())
340
+            if ($subToken->isEncapsedString())
341 341
             {
342 342
                 $textParts[] = $this->trimText(strval($subToken->getValue()));
343 343
                 continue;
344 344
             }
345 345
 
346
-            if($subToken->isVariableOrFunction()) {
346
+            if ($subToken->isVariableOrFunction()) {
347 347
                 $textParts = null;
348 348
                 $this->addWarning($subToken, t('Variables or functions are not supported in translation functions.'));
349 349
                 break;
350 350
             }
351 351
         }
352 352
 
353
-        if(empty($textParts)) {
353
+        if (empty($textParts)) {
354 354
             return '';
355 355
         }
356 356
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
     protected function debug(string $text) : void
361 361
     {
362
-        if($this->debug) {
362
+        if ($this->debug) {
363 363
             echo $text;
364 364
         }
365 365
     }
Please login to merge, or discard this patch.