Passed
Push — master ( 82b8bb...ff0cce )
by Sebastian
03:28
created
src/Localization/Parser/Language.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -124,8 +124,7 @@
 block discarded – undo
124 124
         try
125 125
         {
126 126
             $this->content = FileHelper::readContents($path);
127
-        }
128
-        catch (FileHelper_Exception $e)
127
+        } catch (FileHelper_Exception $e)
129 128
         {
130 129
             throw new Localization_Exception(
131 130
                 sprintf('Source code file [%s] could not be read', basename($path)),
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -23,49 +23,49 @@  discard block
 block discarded – undo
23 23
      */
24 24
     protected $parser;
25 25
 
26
-   /**
27
-    * The function names that are included in the search.
28
-    * @var array
29
-    */
26
+    /**
27
+     * The function names that are included in the search.
28
+     * @var array
29
+     */
30 30
     protected $functionNames = array();
31 31
     
32
-   /**
33
-    * The tokens definitions.
34
-    * @var array
35
-    */
32
+    /**
33
+     * The tokens definitions.
34
+     * @var array
35
+     */
36 36
     protected $tokens = array();
37 37
     
38
-   /**
39
-    * The total amount of tokens found in the content.
40
-    * @var integer
41
-    */
38
+    /**
39
+     * The total amount of tokens found in the content.
40
+     * @var integer
41
+     */
42 42
     protected $totalTokens = 0;
43 43
     
44
-   /**
45
-    * All texts that have been collected.
46
-    * @var Text[]
47
-    */
44
+    /**
45
+     * All texts that have been collected.
46
+     * @var Text[]
47
+     */
48 48
     protected $texts = array();
49 49
     
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected $content = '';
54 54
 
55
-   /**
56
-    * @var string|NULL
57
-    */
55
+    /**
56
+     * @var string|NULL
57
+     */
58 58
     protected $id;
59 59
     
60
-   /**
61
-    * @var Localization_Parser_Warning[]
62
-    */
60
+    /**
61
+     * @var Localization_Parser_Warning[]
62
+     */
63 63
     protected $warnings = array();
64 64
     
65
-   /**
66
-    * The source file that was parsed (if any)
67
-    * @var string
68
-    */
65
+    /**
66
+     * The source file that was parsed (if any)
67
+     * @var string
68
+     */
69 69
     protected $sourceFile = '';
70 70
 
71 71
     /**
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
     
92 92
     abstract protected function getTokens() : array;
93 93
     
94
-   /**
95
-    * Retrieves the ID of the language.
96
-    * @return string E.g. "PHP", "Javascript"
97
-    */
94
+    /**
95
+     * Retrieves the ID of the language.
96
+     * @return string E.g. "PHP", "Javascript"
97
+     */
98 98
     public function getID() : string
99 99
     {
100 100
         if(!isset($this->id)) {
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
         return $this->sourceFile;
115 115
     }
116 116
     
117
-   /**
118
-    * Parses the code from a file.
119
-    * 
120
-    * @param string $path
121
-    * @throws Localization_Exception
122
-    */
117
+    /**
118
+     * Parses the code from a file.
119
+     * 
120
+     * @param string $path
121
+     * @throws Localization_Exception
122
+     */
123 123
     public function parseFile(string $path) : void
124 124
     {
125 125
         if(!file_exists($path)) 
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
         $this->parse();
157 157
     }
158 158
     
159
-   /**
160
-    * Parses a source code string.
161
-    * @param string $content
162
-    */
159
+    /**
160
+     * Parses a source code string.
161
+     * @param string $content
162
+     */
163 163
     public function parseString(string $content) : void
164 164
     {
165 165
         $this->content = $content;
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
         $this->texts[] = new Text($text, $line, $explanation);
215 215
     }
216 216
 
217
-   /**
218
-    * Retrieves a list of all the function names that are
219
-    * used as translation functions in the language.
220
-    * @return array
221
-    */
217
+    /**
218
+     * Retrieves a list of all the function names that are
219
+     * used as translation functions in the language.
220
+     * @return array
221
+     */
222 222
     public function getFunctionNames() : array
223 223
     {
224 224
         return $this->createToken('dummy')->getFunctionNames();
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
         Localization::log(sprintf('%1$s parser | %2$s', $this->getID(), $message));
230 230
     }
231 231
 
232
-   /**
233
-    * Adds a warning message when a text cannot be parsed correctly for some reason.
234
-    * 
235
-    * @param Localization_Parser_Token $token
236
-    * @param string $message
237
-    * @return Localization_Parser_Warning
238
-    */
232
+    /**
233
+     * Adds a warning message when a text cannot be parsed correctly for some reason.
234
+     * 
235
+     * @param Localization_Parser_Token $token
236
+     * @param string $message
237
+     * @return Localization_Parser_Warning
238
+     */
239 239
     protected function addWarning(Localization_Parser_Token $token, string $message) : Localization_Parser_Warning
240 240
     {
241 241
         $warning = new Localization_Parser_Warning($this, $token, $message);
@@ -245,34 +245,34 @@  discard block
 block discarded – undo
245 245
         return $warning;
246 246
     }
247 247
     
248
-   /**
249
-    * Whether any warnings were generated during parsing.
250
-    * @return bool
251
-    */
248
+    /**
249
+     * Whether any warnings were generated during parsing.
250
+     * @return bool
251
+     */
252 252
     public function hasWarnings() : bool
253 253
     {
254 254
         return !empty($this->warnings);
255 255
     }
256 256
     
257
-   /**
258
-    * Retrieves all warnings that were generated during parsing,
259
-    * if any.
260
-    * 
261
-    * @return Localization_Parser_Warning[]
262
-    */
257
+    /**
258
+     * Retrieves all warnings that were generated during parsing,
259
+     * if any.
260
+     * 
261
+     * @return Localization_Parser_Warning[]
262
+     */
263 263
     public function getWarnings() : array
264 264
     {
265 265
         return $this->warnings;
266 266
     }
267 267
     
268
-   /**
269
-    * Creates a token instance: this retrieves information on
270
-    * the language token being parsed.
271
-    * 
272
-    * @param array|string $definition The token definition.
273
-    * @param Localization_Parser_Token|NULL $parentToken
274
-    * @return Localization_Parser_Token
275
-    */
268
+    /**
269
+     * Creates a token instance: this retrieves information on
270
+     * the language token being parsed.
271
+     * 
272
+     * @param array|string $definition The token definition.
273
+     * @param Localization_Parser_Token|NULL $parentToken
274
+     * @return Localization_Parser_Token
275
+     */
276 276
     protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token
277 277
     {
278 278
         $class = Localization_Parser_Token::class.'_'.$this->getID();
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
         return new $class($definition, $parentToken);
281 281
     }
282 282
 
283
-   /**
284
-    * Parses a translation function token.
285
-    * 
286
-    * @param int $number
287
-    * @param Localization_Parser_Token $token
288
-    */
283
+    /**
284
+     * Parses a translation function token.
285
+     * 
286
+     * @param int $number
287
+     * @param Localization_Parser_Token $token
288
+     */
289 289
     protected function parseToken(int $number, Localization_Parser_Token $token) : void
290 290
     {
291 291
         $textParts = array();
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     */
98 98
     public function getID() : string
99 99
     {
100
-        if(!isset($this->id)) {
100
+        if (!isset($this->id)) {
101 101
             $this->id = str_replace(Localization_Parser_Language::class.'_', '', get_class($this));
102 102
         }
103 103
         
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     */
123 123
     public function parseFile(string $path) : void
124 124
     {
125
-        if(!file_exists($path)) 
125
+        if (!file_exists($path)) 
126 126
         {
127 127
             throw new Localization_Exception(
128 128
                 sprintf('Source code file [%s] not found', basename($path)),
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
         $this->tokens = $this->getTokens();
176 176
         $this->totalTokens = count($this->tokens);
177 177
         
178
-        for($i = 0; $i < $this->totalTokens; $i++)
178
+        for ($i = 0; $i < $this->totalTokens; $i++)
179 179
         {
180 180
             $token = $this->createToken($this->tokens[$i]);
181 181
             
182
-            if($token->isTranslationFunction()) {
183
-                $this->parseToken($i+1, $token);
182
+            if ($token->isTranslationFunction()) {
183
+                $this->parseToken($i + 1, $token);
184 184
             }
185 185
         }
186 186
     }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         return self::$allowedContextTags;
205 205
     }
206 206
 
207
-    protected function addResult(string $text, int $line=0, string $explanation='') : void
207
+    protected function addResult(string $text, int $line = 0, string $explanation = '') : void
208 208
     {
209 209
         $this->log(sprintf('Line [%1$s] | Found string [%2$s]', $line, $text));
210 210
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
     * @param Localization_Parser_Token|NULL $parentToken
274 274
     * @return Localization_Parser_Token
275 275
     */
276
-    protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token
276
+    protected function createToken($definition, Localization_Parser_Token $parentToken = null) : Localization_Parser_Token
277 277
     {
278 278
         $class = Localization_Parser_Token::class.'_'.$this->getID();
279 279
         
@@ -293,48 +293,48 @@  discard block
 block discarded – undo
293 293
         $open = false;
294 294
         $explanation = '';
295 295
         
296
-        for($i = $number; $i < $max; $i++)
296
+        for ($i = $number; $i < $max; $i++)
297 297
         {
298
-            if(!isset($this->tokens[$i])) {
298
+            if (!isset($this->tokens[$i])) {
299 299
                 break;
300 300
             }
301 301
             
302 302
             $subToken = $this->createToken($this->tokens[$i], $token);
303 303
             
304
-            if(!$open && $subToken->isOpeningFuncParams())
304
+            if (!$open && $subToken->isOpeningFuncParams())
305 305
             {
306 306
                 $open = true;
307 307
                 continue;
308 308
             }
309 309
             
310
-            if($open && $subToken->isClosingFuncParams()) {
310
+            if ($open && $subToken->isClosingFuncParams()) {
311 311
                 break;
312 312
             }
313 313
             
314 314
             // additional parameters in the translation function, we don't want to capture these now.
315
-            if($open && $subToken->isArgumentSeparator())
315
+            if ($open && $subToken->isArgumentSeparator())
316 316
             {
317
-                if($token->isExplanationFunction()) {
318
-                    $leftover = array_slice($this->tokens, $i+1);
317
+                if ($token->isExplanationFunction()) {
318
+                    $leftover = array_slice($this->tokens, $i + 1);
319 319
                     $explanation = $this->parseExplanation($token, $leftover);
320 320
                 }
321 321
                 break;
322 322
             }
323 323
             
324
-            if($open && $subToken->isEncapsedString())
324
+            if ($open && $subToken->isEncapsedString())
325 325
             {
326 326
                 $textParts[] = $this->trimText(strval($subToken->getValue()));
327 327
                 continue;
328 328
             }
329 329
             
330
-            if($open && $subToken->isVariableOrFunction()) {
330
+            if ($open && $subToken->isVariableOrFunction()) {
331 331
                 $textParts = null;
332 332
                 $this->addWarning($subToken, t('Variables or functions are not supported in translation functions.'));
333 333
                 break;
334 334
             }
335 335
         }
336 336
         
337
-        if(empty($textParts)) {
337
+        if (empty($textParts)) {
338 338
             return;
339 339
         }
340 340
         
@@ -348,38 +348,38 @@  discard block
 block discarded – undo
348 348
         $textParts = array();
349 349
         $max = 200;
350 350
 
351
-        for($i = 0; $i < $max; $i++)
351
+        for ($i = 0; $i < $max; $i++)
352 352
         {
353
-            if(!isset($tokens[$i])) {
353
+            if (!isset($tokens[$i])) {
354 354
                 break;
355 355
             }
356 356
 
357 357
             $subToken = $this->createToken($tokens[$i], $token);
358 358
 
359
-            if($subToken->isClosingFuncParams()) {
359
+            if ($subToken->isClosingFuncParams()) {
360 360
                 break;
361 361
             }
362 362
 
363 363
             // additional parameters in the translation function, we don't want to capture these now.
364
-            if($subToken->isArgumentSeparator())
364
+            if ($subToken->isArgumentSeparator())
365 365
             {
366 366
                 break;
367 367
             }
368 368
 
369
-            if($subToken->isEncapsedString())
369
+            if ($subToken->isEncapsedString())
370 370
             {
371 371
                 $textParts[] = $this->trimText(strval($subToken->getValue()));
372 372
                 continue;
373 373
             }
374 374
 
375
-            if($subToken->isVariableOrFunction()) {
375
+            if ($subToken->isVariableOrFunction()) {
376 376
                 $textParts = null;
377 377
                 $this->addWarning($subToken, t('Variables or functions are not supported in translation functions.'));
378 378
                 break;
379 379
             }
380 380
         }
381 381
 
382
-        if(empty($textParts)) {
382
+        if (empty($textParts)) {
383 383
             return '';
384 384
         }
385 385
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
     protected function debug(string $text) : void
390 390
     {
391
-        if($this->debug) {
391
+        if ($this->debug) {
392 392
             echo $text;
393 393
         }
394 394
     }
Please login to merge, or discard this patch.
src/Localization/Event/LocaleChanged.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
     const ERROR_NO_CURRENT_LOCALE_SPECIFIED = 91401;
26 26
 
27 27
     /**
28
-    * The locale that was used before the change, if any.
29
-    * @return Localization_Locale|NULL
30
-    */
28
+     * The locale that was used before the change, if any.
29
+     * @return Localization_Locale|NULL
30
+     */
31 31
     public function getPrevious() : ?Localization_Locale
32 32
     {
33 33
         $arg = $this->getArgument(1);
@@ -59,28 +59,28 @@  discard block
 block discarded – undo
59 59
         );
60 60
     }
61 61
     
62
-   /**
63
-    * The namespace in which the locale change occurred.
64
-    * @return string
65
-    */
62
+    /**
63
+     * The namespace in which the locale change occurred.
64
+     * @return string
65
+     */
66 66
     public function getNamespace() : string
67 67
     {
68 68
         return strval($this->getArgument(0));
69 69
     }
70 70
 
71
-   /**
72
-    * Whether the change occurred for an application locale.
73
-    * @return bool
74
-    */
71
+    /**
72
+     * Whether the change occurred for an application locale.
73
+     * @return bool
74
+     */
75 75
     public function isAppLocale() : bool
76 76
     {
77 77
         return $this->getNamespace() === Localization::NAMESPACE_APPLICATION;
78 78
     }
79 79
     
80
-   /**
81
-    * Whether the change occurred for a content locale.
82
-    * @return bool
83
-    */
80
+    /**
81
+     * Whether the change occurred for a content locale.
82
+     * @return bool
83
+     */
84 84
     public function isContentLocale() : bool
85 85
     {
86 86
         return $this->getNamespace() === Localization::NAMESPACE_CONTENT;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function getPrevious() : ?Localization_Locale
32 32
     {
33 33
         $arg = $this->getArgument(1);
34
-        if($arg instanceof Localization_Locale) {
34
+        if ($arg instanceof Localization_Locale) {
35 35
             return $arg;
36 36
         }
37 37
         
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $arg = $this->getArgument(2);
50 50
 
51
-        if($arg instanceof Localization_Locale) {
51
+        if ($arg instanceof Localization_Locale) {
52 52
             return $arg;
53 53
         }
54 54
 
Please login to merge, or discard this patch.
src/Localization/Scanner.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,24 +24,24 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class Localization_Scanner
26 26
 {
27
-   /**
28
-    * @var float
29
-    */
27
+    /**
28
+     * @var float
29
+     */
30 30
     protected $timeStart;
31 31
     
32
-   /**
33
-    * @var float
34
-    */
32
+    /**
33
+     * @var float
34
+     */
35 35
     protected $timeEnd;
36 36
     
37
-   /**
38
-    * @var array
39
-    */
37
+    /**
38
+     * @var array
39
+     */
40 40
     protected $stringInfos = array();
41 41
     
42
-   /**
43
-    * @var string
44
-    */
42
+    /**
43
+     * @var string
44
+     */
45 45
     protected $storageFile;
46 46
 
47 47
     /**
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
         return $this->getCollection()->countWarnings();
173 173
     }
174 174
     
175
-   /**
176
-    * Retrieves all warnings that have been registered
177
-    * during the last search for translatable texts.
178
-    * 
179
-    * @return Localization_Scanner_StringsCollection_Warning[]
180
-    */
175
+    /**
176
+     * Retrieves all warnings that have been registered
177
+     * during the last search for translatable texts.
178
+     * 
179
+     * @return Localization_Scanner_StringsCollection_Warning[]
180
+     */
181 181
     public function getWarnings() : array
182 182
     {
183 183
         return $this->getCollection()->getWarnings();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
     
73 73
     public function scan() : void
74 74
     {
75
-        if(isset($this->collection)) {
75
+        if (isset($this->collection)) {
76 76
             $this->collection = null;
77 77
         }
78 78
         
79 79
         $this->timeStart = microtime(true);
80 80
         
81 81
         $sources = Localization::getSources();
82
-        foreach($sources as $source) 
82
+        foreach ($sources as $source) 
83 83
         {
84 84
             $source->scan($this);
85 85
         }
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 
92 92
     public function load() : void
93 93
     {
94
-        if(!$this->isScanAvailable()) {
94
+        if (!$this->isScanAvailable()) {
95 95
             return;
96 96
         }
97 97
         
98
-        if($this->loaded) {
98
+        if ($this->loaded) {
99 99
             return;
100 100
         }
101 101
         
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         
104 104
         $data = FileHelper::parseJSONFile($this->storageFile);
105 105
         
106
-        if($this->getCollection()->fromArray($data) === true) {
106
+        if ($this->getCollection()->fromArray($data) === true) {
107 107
             return;
108 108
         }
109 109
         
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     
122 122
     public function getParser() : Localization_Parser
123 123
     {
124
-        if(!isset($this->parser)) {
124
+        if (!isset($this->parser)) {
125 125
             $this->parser = new Localization_Parser($this);
126 126
         }
127 127
         
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     
131 131
     public function getCollection() : Localization_Scanner_StringsCollection
132 132
     {
133
-        if(!isset($this->collection)) {
133
+        if (!isset($this->collection)) {
134 134
             $this->collection = new Localization_Scanner_StringsCollection($this);
135 135
         }
136 136
         
Please login to merge, or discard this patch.
src/Localization/Currency.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
             return self::$instances[$id];
74 74
         }
75 75
 
76
-        $className = Localization_Currency::class.'_' . $id;
76
+        $className = Localization_Currency::class.'_'.$id;
77 77
 
78 78
         $country = new $className($country);
79 79
 
80
-        if($country instanceof Localization_Currency)
80
+        if ($country instanceof Localization_Currency)
81 81
         {
82 82
             return $country;
83 83
         }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public static function isCurrencyKnown(string $currencyName) : bool
140 140
     {
141
-        return file_exists(__DIR__ . '/Currency/' . $currencyName . '.php');
141
+        return file_exists(__DIR__.'/Currency/'.$currencyName.'.php');
142 142
     }
143 143
 
144 144
     /**
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
      * @return string
351 351
      * @throws Localization_Exception
352 352
      */
353
-    public function makeReadable($number, int $decimalPositions = 2, bool $addSymbol=true) : string
353
+    public function makeReadable($number, int $decimalPositions = 2, bool $addSymbol = true) : string
354 354
     {
355 355
         if ($number === null || $number === '') {
356 356
             return '';
@@ -360,14 +360,14 @@  discard block
 block discarded – undo
360 360
 
361 361
         $number = $this->formatNumber($parsed->getFloat(), $decimalPositions);
362 362
 
363
-        if(!$addSymbol) {
363
+        if (!$addSymbol) {
364 364
             return $number;
365 365
         }
366 366
         
367 367
         if ($this->isSymbolOnFront()) {
368
-            return $this->getSymbol() . ' ' . $number;
368
+            return $this->getSymbol().' '.$number;
369 369
         }
370 370
 
371
-        return $number . ' ' . $this->getSymbol();
371
+        return $number.' '.$this->getSymbol();
372 372
     }
373 373
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -245,8 +245,7 @@
 block discarded – undo
245 245
             if ($decimals == '-') {
246 246
                 $decimals = 0;
247 247
             }
248
-        } 
249
-        else 
248
+        } else 
250 249
         {
251 250
             $decimals = 0;
252 251
             $thousands = implode('', $parts);
Please login to merge, or discard this patch.
src/Localization/Scanner/StringsCollection.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@  discard block
 block discarded – undo
12 12
     
13 13
     const STORAGE_FORMAT_VERSION = 2;
14 14
     
15
-   /**
16
-    * @var Localization_Scanner
17
-    */
15
+    /**
16
+     * @var Localization_Scanner
17
+     */
18 18
     protected $scanner;
19 19
     
20
-   /**
21
-    * @var Localization_Scanner_StringHash[]
22
-    */
20
+    /**
21
+     * @var Localization_Scanner_StringHash[]
22
+     */
23 23
     protected $hashes = array();
24 24
     
25
-   /**
26
-    * @var array
27
-    */
25
+    /**
26
+     * @var array
27
+     */
28 28
     protected $warnings = array();
29 29
     
30 30
     public function __construct(Localization_Scanner $scanner)
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
         return new Localization_Scanner_StringInfo($this, $sourceID, $sourceType, $text);
53 53
     }
54 54
     
55
-   /**
56
-    * Adds a single translatable string.
57
-    * 
58
-    * @param Localization_Scanner_StringInfo $string
59
-    * @return Localization_Scanner_StringsCollection
60
-    */
55
+    /**
56
+     * Adds a single translatable string.
57
+     * 
58
+     * @param Localization_Scanner_StringInfo $string
59
+     * @return Localization_Scanner_StringsCollection
60
+     */
61 61
     protected function add(Localization_Scanner_StringInfo $string) : Localization_Scanner_StringsCollection
62 62
     {
63 63
         $hash = $string->getHash();
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
         return $this;
71 71
     }
72 72
     
73
-   /**
74
-    * Retrieves all available translatable strings,
75
-    * grouped by their hash to identify unique strings.
76
-    * 
77
-    * @return Localization_Scanner_StringHash[]
78
-    */
73
+    /**
74
+     * Retrieves all available translatable strings,
75
+     * grouped by their hash to identify unique strings.
76
+     * 
77
+     * @return Localization_Scanner_StringHash[]
78
+     */
79 79
     public function getHashes() : array
80 80
     {
81 81
         return array_values($this->hashes);
@@ -146,32 +146,32 @@  discard block
 block discarded – undo
146 146
         return true;
147 147
     }
148 148
     
149
-   /**
150
-    * Whether the parser reported warnings during the
151
-    * search for translatable texts.
152
-    * 
153
-    * @return bool
154
-    */
149
+    /**
150
+     * Whether the parser reported warnings during the
151
+     * search for translatable texts.
152
+     * 
153
+     * @return bool
154
+     */
155 155
     public function hasWarnings() : bool
156 156
     {
157 157
         return !empty($this->warnings);
158 158
     }
159 159
     
160
-   /**
161
-    * Retrieves the amount of warnings.
162
-    * @return int
163
-    */
160
+    /**
161
+     * Retrieves the amount of warnings.
162
+     * @return int
163
+     */
164 164
     public function countWarnings() : int
165 165
     {
166 166
         return count($this->warnings);
167 167
     }
168 168
     
169
-   /**
170
-    * Retrieves all warning messages that were added
171
-    * during the search for translatable texts, if any.
172
-    * 
173
-    * @return Localization_Scanner_StringsCollection_Warning[]
174
-    */
169
+    /**
170
+     * Retrieves all warning messages that were added
171
+     * during the search for translatable texts, if any.
172
+     * 
173
+     * @return Localization_Scanner_StringsCollection_Warning[]
174
+     */
175 175
     public function getWarnings() : array
176 176
     {
177 177
         $result = array();
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
         return $amount;
199 199
     }
200 200
     
201
-   /**
202
-    * Retrieves all string hashed for the specified source.
203
-    * 
204
-    * @param string $id
205
-    * @return Localization_Scanner_StringHash[]
206
-    */
201
+    /**
202
+     * Retrieves all string hashed for the specified source.
203
+     * 
204
+     * @param string $id
205
+     * @return Localization_Scanner_StringHash[]
206
+     */
207 207
     public function getHashesBySourceID(string $id) : array
208 208
     {
209 209
         $hashes = array();
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
         return $hashes;
218 218
     }
219 219
     
220
-   /**
221
-    * Retrieves all hashes for the specified language ID.
222
-    * 
223
-    * @param string $languageID The language ID, e.g. "PHP"
224
-    * @return Localization_Scanner_StringHash[]
225
-    */
220
+    /**
221
+     * Retrieves all hashes for the specified language ID.
222
+     * 
223
+     * @param string $languageID The language ID, e.g. "PHP"
224
+     * @return Localization_Scanner_StringHash[]
225
+     */
226 226
     public function getHashesByLanguageID(string $languageID) : array
227 227
     {
228 228
         $hashes = array();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $hash = $string->getHash();
64 64
         
65
-        if(!isset($this->hashes[$hash])) {
65
+        if (!isset($this->hashes[$hash])) {
66 66
             $this->hashes[$hash] = new Localization_Scanner_StringHash($this, $hash);
67 67
         }
68 68
         
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getHash(string $hash) : Localization_Scanner_StringHash
95 95
     {
96
-        if(isset($this->hashes[$hash])) {
96
+        if (isset($this->hashes[$hash])) {
97 97
             return $this->hashes[$hash];
98 98
         }
99 99
         
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             'warnings' => array()
116 116
         );
117 117
         
118
-        foreach($this->hashes as $hash)
118
+        foreach ($this->hashes as $hash)
119 119
         {
120 120
             $data['hashes'] = array_merge($data['hashes'], $hash->toArray());
121 121
         }
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function fromArray(array $array) : bool
133 133
     {
134
-        if(!isset($array['formatVersion']) || $array['formatVersion'] != self::STORAGE_FORMAT_VERSION) {
134
+        if (!isset($array['formatVersion']) || $array['formatVersion'] != self::STORAGE_FORMAT_VERSION) {
135 135
             return false;
136 136
         }
137 137
         
138
-        foreach($array['hashes'] as $entry) 
138
+        foreach ($array['hashes'] as $entry) 
139 139
         {
140 140
             $string = Localization_Scanner_StringInfo::fromArray($this, $entry);
141 141
             $this->add($string);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     {
177 177
         $result = array();
178 178
         
179
-        foreach($this->warnings as $def) {
179
+        foreach ($this->warnings as $def) {
180 180
             $result[] = new Localization_Scanner_StringsCollection_Warning($def);
181 181
         }
182 182
         
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     public function countFiles() : int
192 192
     {
193 193
         $amount = 0;
194
-        foreach($this->hashes as $hash) {
194
+        foreach ($this->hashes as $hash) {
195 195
             $amount = $amount + $hash->countFiles();
196 196
         }
197 197
         
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
     {
209 209
         $hashes = array();
210 210
         
211
-        foreach($this->hashes as $hash) {
212
-            if($hash->hasSourceID($id)) {
211
+        foreach ($this->hashes as $hash) {
212
+            if ($hash->hasSourceID($id)) {
213 213
                 $hashes[] = $hash;
214 214
             }
215 215
         }
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
     {
228 228
         $hashes = array();
229 229
         
230
-        foreach($this->hashes as $hash) {
231
-            if($hash->hasLanguageType($languageID)) {
230
+        foreach ($this->hashes as $hash) {
231
+            if ($hash->hasLanguageType($languageID)) {
232 232
                 $hashes[] = $hash;
233 233
             }
234 234
         }
Please login to merge, or discard this patch.
src/Localization/Editor/OutputBuffering.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     {
22 22
         $html = ob_get_clean();
23 23
 
24
-        if($html !== false)
24
+        if ($html !== false)
25 25
         {
26 26
             return $html;
27 27
         }
Please login to merge, or discard this patch.
src/Localization/Editor.php 3 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -37,54 +37,54 @@  discard block
 block discarded – undo
37 37
     const ERROR_NO_SOURCES_AVAILABLE = 40001;
38 38
     const ERROR_LOCAL_PATH_NOT_FOUND = 40002;
39 39
 
40
-   /**
41
-    * @var string
42
-    */
40
+    /**
41
+     * @var string
42
+     */
43 43
     protected $installPath;
44 44
     
45
-   /**
46
-    * @var Localization_Source[]
47
-    */
45
+    /**
46
+     * @var Localization_Source[]
47
+     */
48 48
     protected $sources;
49 49
     
50
-   /**
51
-    * @var Request
52
-    */
50
+    /**
51
+     * @var Request
52
+     */
53 53
     protected $request;
54 54
     
55
-   /**
56
-    * @var Localization_Source
57
-    */
55
+    /**
56
+     * @var Localization_Source
57
+     */
58 58
     protected $activeSource;
59 59
     
60
-   /**
61
-    * @var Localization_Scanner
62
-    */
60
+    /**
61
+     * @var Localization_Scanner
62
+     */
63 63
     protected $scanner;
64 64
     
65
-   /**
66
-    * @var Localization_Locale[]
67
-    */
65
+    /**
66
+     * @var Localization_Locale[]
67
+     */
68 68
     protected $appLocales = array();
69 69
     
70
-   /**
71
-    * @var Localization_Locale
72
-    */
70
+    /**
71
+     * @var Localization_Locale
72
+     */
73 73
     protected $activeAppLocale;
74 74
     
75
-   /**
76
-    * @var Localization_Editor_Filters
77
-    */
75
+    /**
76
+     * @var Localization_Editor_Filters
77
+     */
78 78
     protected $filters;
79 79
 
80
-   /**
81
-    * @var array<string,string>
82
-    */
80
+    /**
81
+     * @var array<string,string>
82
+     */
83 83
     protected $requestParams = array();
84 84
     
85
-   /**
86
-    * @var string
87
-    */
85
+    /**
86
+     * @var string
87
+     */
88 88
     protected $varPrefix = 'applocalize_';
89 89
 
90 90
     /**
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
         return $this->request;
126 126
     }
127 127
     
128
-   /**
129
-    * Adds a request parameter that will be persisted in all URLs
130
-    * within the editor. This can be used when integrating the
131
-    * editor in an existing page that needs specific request params.
132
-    * 
133
-    * @param string $name
134
-    * @param string $value
135
-    * @return Localization_Editor
136
-    */
128
+    /**
129
+     * Adds a request parameter that will be persisted in all URLs
130
+     * within the editor. This can be used when integrating the
131
+     * editor in an existing page that needs specific request params.
132
+     * 
133
+     * @param string $name
134
+     * @param string $value
135
+     * @return Localization_Editor
136
+     */
137 137
     public function addRequestParam(string $name, string $value) : Localization_Editor
138 138
     {
139 139
         $this->requestParams[$name] = $value;
@@ -295,34 +295,34 @@  discard block
 block discarded – undo
295 295
                                 	</a>
296 296
                                     <div class="dropdown-menu" aria-labelledby="dropdown01">
297 297
                                     	<?php 
298
-                                    	    foreach($this->sources as $source)
299
-                                    	    {
300
-                                    	       ?>
298
+                                            foreach($this->sources as $source)
299
+                                            {
300
+                                                ?>
301 301
                                         			<a class="dropdown-item" href="<?php echo $this->getSourceURL($source) ?>">
302 302
                                         				<?php 
303
-                                            				if($source->getID() === $this->activeSource->getID()) 
304
-                                            				{
305
-                                            				    ?>
303
+                                                            if($source->getID() === $this->activeSource->getID()) 
304
+                                                            {
305
+                                                                ?>
306 306
                                             				    	<b><?php echo $source->getLabel() ?></b>
307 307
                                         				    	<?php 
308
-                                            				}
309
-                                            				else
310
-                                            				{
311
-                                            				    echo $source->getLabel();
312
-                                            				}
313
-                                        				?>
308
+                                                            }
309
+                                                            else
310
+                                                            {
311
+                                                                echo $source->getLabel();
312
+                                                            }
313
+                                                        ?>
314 314
                                         				<?php
315
-                                        				    $untranslated = $source->countUntranslated($this->scanner);
316
-                                        				    if($untranslated > 0) {
317
-                                        				        ?>
315
+                                                            $untranslated = $source->countUntranslated($this->scanner);
316
+                                                            if($untranslated > 0) {
317
+                                                                ?>
318 318
                                         				        	(<span class="text-danger" title="<?php ptex('%1$s texts have not been translated in this text source.', 'Amount of texts', $untranslated) ?>"><?php echo $untranslated ?></span>)
319 319
                                 				            	<?php 
320
-                                        				    }
321
-                                    				    ?>
320
+                                                            }
321
+                                                        ?>
322 322
                                     				</a>
323 323
                                     			<?php 
324
-                                    	    }
325
-                                	    ?>
324
+                                            }
325
+                                        ?>
326 326
                                     </div>
327 327
                                 </li>
328 328
                                 <li class="nav-item dropdown">
@@ -331,15 +331,15 @@  discard block
 block discarded – undo
331 331
                                 	</a>
332 332
                                     <div class="dropdown-menu" aria-labelledby="dropdown01">
333 333
                                     	<?php 
334
-                                    	    foreach($this->appLocales as $locale)
335
-                                    	    {
336
-                                    	       ?>
334
+                                            foreach($this->appLocales as $locale)
335
+                                            {
336
+                                                ?>
337 337
                                         			<a class="dropdown-item" href="<?php echo $this->getLocaleURL($locale) ?>">
338 338
                                         				<?php echo $locale->getLabel() ?>
339 339
                                     				</a>
340 340
                                     			<?php 
341
-                                    	    }
342
-                                	    ?>
341
+                                            }
342
+                                        ?>
343 343
                                     </div>
344 344
                                 </li>
345 345
                                 <li class="nav-item">
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
                                     </a>
350 350
                     			</li>
351 351
                     			<?php 
352
-                        			if($this->scanner->hasWarnings()) {
353
-                        			    ?>
352
+                                    if($this->scanner->hasWarnings()) {
353
+                                        ?>
354 354
                         			    	<li class="nav-item">
355 355
                         			    		<a href="<?php echo $this->getWarningsURL() ?>">
356 356
                             			    		<span class="badge badge-warning" title="<?php pts('The last scan for translatable texts reported warnings.'); pts('Click for details.'); ?>" data-toggle="tooltip">
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
                         			    		</a>
361 361
                         			    	</li>
362 362
                         			    <?php 
363
-                        			}
364
-                    			?>
363
+                                    }
364
+                                ?>
365 365
                             </ul>
366 366
                         <?php 
367 367
                     }
@@ -377,36 +377,36 @@  discard block
 block discarded – undo
377 377
                         	</a>
378 378
                     	<?php 
379 379
                     }
380
-            	?>
380
+                ?>
381 381
     		</div>
382 382
 		</nav>
383 383
 		<main role="main" class="container">
384 384
 			<div>
385 385
     			<?php 
386
-    			    if(empty($this->appLocales))
387
-    			    {
388
-    			        ?>
386
+                    if(empty($this->appLocales))
387
+                    {
388
+                        ?>
389 389
     			        	<div class="alert alert-danger">
390 390
     			        		<i class="fa fa-exclamation-triangle"></i>
391 391
     			        		<b><?php pt('Nothing to translate:') ?></b>
392 392
     			        		<?php pt('No application locales were added to translate to.') ?>
393 393
     			        	</div>
394 394
     			        <?php 
395
-    			    }
396
-    			    else if($this->request->getBool($this->getVarName('warnings')))
397
-    			    {
398
-    			        echo $this->renderWarnings();
399
-    			    }
400
-    			    else
401
-    			    {
402
-    			        ?>
395
+                    }
396
+                    else if($this->request->getBool($this->getVarName('warnings')))
397
+                    {
398
+                        echo $this->renderWarnings();
399
+                    }
400
+                    else
401
+                    {
402
+                        ?>
403 403
             				<h1><?php echo $this->activeSource->getLabel() ?></h1>
404 404
             				<?php 
405
-                				if(!empty($_SESSION['localization_messages'])) 
406
-                				{
407
-                				    foreach($_SESSION['localization_messages'] as $def)
408
-                				    {
409
-                				        ?>
405
+                                if(!empty($_SESSION['localization_messages'])) 
406
+                                {
407
+                                    foreach($_SESSION['localization_messages'] as $def)
408
+                                    {
409
+                                        ?>
410 410
                 				        	<div class="alert alert-<?php echo $def['type'] ?>" role="alert">
411 411
                                         		<?php echo $def['text'] ?>
412 412
                                         		<button type="button" class="close" data-dismiss="alert" aria-label="<?php pt('Close') ?>" title="<?php pt('Dismiss this message.') ?>" data-toggle="tooltip">
@@ -414,28 +414,28 @@  discard block
 block discarded – undo
414 414
             									</button>
415 415
                                         	</div>
416 416
             				        	<?php 
417
-                				    }
417
+                                    }
418 418
                 				    
419
-                				    // reset the messages after having displayed them
420
-                				    $_SESSION['localization_messages'] = array();
421
-                				}
422
-            				?>
419
+                                    // reset the messages after having displayed them
420
+                                    $_SESSION['localization_messages'] = array();
421
+                                }
422
+                            ?>
423 423
             				<p>
424 424
             					<?php 
425
-            				        pt(
426
-                					    'You are translating to %1$s', 
427
-                					    '<span class="badge badge-info">'.
428
-                					       $this->activeAppLocale->getLabel().
429
-                				        '</span>'
425
+                                    pt(
426
+                                        'You are translating to %1$s', 
427
+                                        '<span class="badge badge-info">'.
428
+                                            $this->activeAppLocale->getLabel().
429
+                                        '</span>'
430 430
                                     );
431
-            				    ?><br>
431
+                                ?><br>
432 432
             					<?php pt('Found %1$s texts to translate.', $this->activeSource->countUntranslated($this->scanner)) ?>
433 433
             				</p>
434 434
             				<br>
435 435
             				<?php
436
-                				if(!$this->scanner->isScanAvailable()) 
437
-                				{
438
-                				    ?>
436
+                                if(!$this->scanner->isScanAvailable()) 
437
+                                {
438
+                                    ?>
439 439
                 				    	<div class="alert alert-primary" role="alert">
440 440
                                         	<b><?php pt('No texts found:') ?></b> 
441 441
                                         	<?php pt('The source folders have not been scanned yet.') ?>
@@ -447,15 +447,15 @@  discard block
 block discarded – undo
447 447
                                             </a>
448 448
                                         </p>
449 449
                 				    <?php 
450
-                				}
451
-                				else
452
-                				{
453
-                				    echo $this->filters->renderForm();
450
+                                }
451
+                                else
452
+                                {
453
+                                    echo $this->filters->renderForm();
454 454
 
455
-                				    $this->displayList();
456
-                				}
457
-        				}
458
-    				?>
455
+                                    $this->displayList();
456
+                                }
457
+                        }
458
+                    ?>
459 459
 			</div>
460 460
 		</main>
461 461
 	</body>
@@ -473,22 +473,22 @@  discard block
 block discarded – undo
473 473
         	<h1><?php pt('Warnings') ?></h1>
474 474
         	<p class="abstract">
475 475
         		<?php 
476
-        		    pts('The following shows all texts where the system decided that they cannot be translated.');
477
-       		    ?>
476
+                    pts('The following shows all texts where the system decided that they cannot be translated.');
477
+                    ?>
478 478
         	</p>
479 479
         	<dl>
480 480
         		<?php 
481
-        		    $warnings = $this->scanner->getWarnings();
481
+                    $warnings = $this->scanner->getWarnings();
482 482
         		    
483
-        		    foreach($warnings as $warning)
484
-        		    {
485
-        		        ?>
483
+                    foreach($warnings as $warning)
484
+                    {
485
+                        ?>
486 486
         		        	<dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt>
487 487
         		        	<dd><?php echo $warning->getMessage() ?></dd>
488 488
         		        <?php 
489
-        		    }
489
+                    }
490 490
         		        
491
-        		?>
491
+                ?>
492 492
         	</dl>
493 493
     	<?php 
494 494
 
@@ -558,13 +558,13 @@  discard block
 block discarded – undo
558 558
 			<form method="post">
559 559
 				<div class="form-hiddens">
560 560
 					<?php 
561
-    					$params = $this->getRequestParams();
562
-    					foreach($params as $name => $value) {
563
-    					    ?>
561
+                        $params = $this->getRequestParams();
562
+                        foreach($params as $name => $value) {
563
+                            ?>
564 564
     					    	<input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>">
565 565
     					    <?php 
566
-    					}
567
-					?>
566
+                        }
567
+                    ?>
568 568
 				</div>
569 569
             	<table class="table table-hover">
570 570
     				<thead>
@@ -577,20 +577,20 @@  discard block
 block discarded – undo
577 577
     				</thead>
578 578
     				<tbody>
579 579
     					<?php 
580
-    					    foreach($keep as $string)
581
-    					    {
582
-    					        $this->renderListEntry($string);
583
-    					    }
584
-    					?>
580
+                            foreach($keep as $string)
581
+                            {
582
+                                $this->renderListEntry($string);
583
+                            }
584
+                        ?>
585 585
     				</tbody>
586 586
     			</table>
587 587
     			<?php 
588
-        			if($pager->hasPages()) 
589
-        			{
590
-        			    $prevUrl = $this->getPaginationURL($pager->getPreviousPage());
591
-        			    $nextUrl = $this->getPaginationURL($pager->getNextPage());
588
+                    if($pager->hasPages()) 
589
+                    {
590
+                        $prevUrl = $this->getPaginationURL($pager->getPreviousPage());
591
+                        $nextUrl = $this->getPaginationURL($pager->getNextPage());
592 592
         			    
593
-        			    ?>
593
+                        ?>
594 594
         			    	<nav aria-label="<?php pt('Navigate available pages of texts.') ?>">
595 595
                                 <ul class="pagination">
596 596
                                     <li class="page-item">
@@ -599,20 +599,20 @@  discard block
 block discarded – undo
599 599
                                 		</a>
600 600
                             		</li>
601 601
                             		<?php 
602
-                            		    $numbers = $pager->getPageNumbers();
603
-                            		    foreach($numbers as $number) 
604
-                            		    {
605
-                            		        $url = $this->getPaginationURL($number);
602
+                                        $numbers = $pager->getPageNumbers();
603
+                                        foreach($numbers as $number) 
604
+                                        {
605
+                                            $url = $this->getPaginationURL($number);
606 606
                             		        
607
-                            		        ?>
607
+                                            ?>
608 608
                             		        	<li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>">
609 609
                             		        		<a class="page-link" href="<?php echo $url ?>">
610 610
                             		        			<?php echo $number ?>
611 611
                         		        			</a>
612 612
                         		        		</li>
613 613
                             		        <?php 
614
-                            		    }
615
-                            		?>
614
+                                        }
615
+                                    ?>
616 616
                                     <li class="page-item">
617 617
                                     	<a class="page-link" href="<?php echo $nextUrl ?>">
618 618
                                     		<i class="fa fa-arrow-right"></i>
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
                                 </ul>
622 622
                             </nav>
623 623
         			    <?php 
624
-        			}
625
-    			?>
624
+                    }
625
+                ?>
626 626
 				<br>
627 627
 				<p>
628 628
 					<button type="submit" name="<?php echo $this->getVarName('save') ?>" value="yes" class="btn btn-primary">
@@ -693,46 +693,46 @@  discard block
 block discarded – undo
693 693
         			<div class="files-list">
694 694
             			<p>
695 695
             				<?php 
696
-            				    $totalFiles = count($files);
696
+                                $totalFiles = count($files);
697 697
             				    
698
-            				    if($totalFiles == 1)
699
-            				    {
700
-            				        pt('Found in a single file:');
701
-            				    }
702
-            				    else
703
-            				    {
704
-            				        pt('Found in %1$s files:', $totalFiles);
705
-            				    }
706
-    				        ?>
698
+                                if($totalFiles == 1)
699
+                                {
700
+                                    pt('Found in a single file:');
701
+                                }
702
+                                else
703
+                                {
704
+                                    pt('Found in %1$s files:', $totalFiles);
705
+                                }
706
+                            ?>
707 707
             			</p>
708 708
         				<div class="files-scroller">
709 709
                 			<ul>
710 710
                 				<?php 
711
-                				    $locations = $string->getStrings();
711
+                                    $locations = $string->getStrings();
712 712
                 				    
713
-                    				foreach($locations as $location) 
714
-                    				{
715
-                    				    $file = $location->getSourceFile();
716
-                    				    $line = $location->getLine();
713
+                                    foreach($locations as $location) 
714
+                                    {
715
+                                        $file = $location->getSourceFile();
716
+                                        $line = $location->getLine();
717 717
                     				    
718
-                    				    $ext = FileHelper::getExtension($file);
718
+                                        $ext = FileHelper::getExtension($file);
719 719
                     				    
720
-                    				    if($ext == 'php') {
721
-                    				        $icon = 'fab fa-php';
722
-                    				    } else if($ext == 'js') {
723
-                    				        $icon = 'fab fa-js-square';
724
-                    				    } else {
725
-                    				        $icon = 'fas fa-file-code';
726
-                    				    }
720
+                                        if($ext == 'php') {
721
+                                            $icon = 'fab fa-php';
722
+                                        } else if($ext == 'js') {
723
+                                            $icon = 'fab fa-js-square';
724
+                                        } else {
725
+                                            $icon = 'fas fa-file-code';
726
+                                        }
727 727
                     				    
728
-                    				    ?>
728
+                                        ?>
729 729
                     				    	<li>
730 730
                     				    		<i class="<?php echo $icon ?>"></i>
731 731
                     				    		<?php echo $file ?><span class="line-number">:<?php echo $line ?></span>
732 732
                     				    	</li>
733 733
                     				    <?php 
734
-                    				}
735
-                				?>
734
+                                    }
735
+                                ?>
736 736
                 			</ul>
737 737
             			</div>
738 738
         			</div>
@@ -949,13 +949,13 @@  discard block
 block discarded – undo
949 949
         );
950 950
     }
951 951
     
952
-   /**
953
-    * Sets the application name shown in the main navigation
954
-    * in the user interface.
955
-    * 
956
-    * @param string $name
957
-    * @return Localization_Editor
958
-    */
952
+    /**
953
+     * Sets the application name shown in the main navigation
954
+     * in the user interface.
955
+     * 
956
+     * @param string $name
957
+     * @return Localization_Editor
958
+     */
959 959
     public function setAppName(string $name) : Localization_Editor
960 960
     {
961 961
         $this->setOption('appname', $name);
@@ -985,15 +985,15 @@  discard block
 block discarded – undo
985 985
         return $this;
986 986
     }
987 987
     
988
-   /**
989
-    * Sets an URL that the translators can use to go back to
990
-    * the main application, for example if it is integrated into
991
-    * an existing application.
992
-    * 
993
-    * @param string $url The URL to use for the link
994
-    * @param string $label Label of the link
995
-    * @return Localization_Editor
996
-    */
988
+    /**
989
+     * Sets an URL that the translators can use to go back to
990
+     * the main application, for example if it is integrated into
991
+     * an existing application.
992
+     * 
993
+     * @param string $url The URL to use for the link
994
+     * @param string $label Label of the link
995
+     * @return Localization_Editor
996
+     */
997 997
     public function setBackURL(string $url, string $label) : Localization_Editor
998 998
     {
999 999
         $this->setOption('back-url', $url);
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 namespace AppLocalize;
13 13
 
14
-use AppLocalize\Editor\OutputBuffering;use AppUtils\ConvertHelper;
14
+use AppLocalize\Editor\OutputBuffering; use AppUtils\ConvertHelper;
15 15
 use AppUtils\PaginationHelper;
16 16
 use AppUtils\Traits_Optionable;
17 17
 use AppUtils\Interface_Optionable;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     public function __construct()
100 100
     {
101 101
         $path = realpath(__DIR__.'/../');
102
-        if($path === false)
102
+        if ($path === false)
103 103
         {
104 104
             throw new Localization_Exception(
105 105
                 'Local path not found',
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
     
153 153
     protected function initSession() : void
154 154
     {
155
-        if(session_status() != PHP_SESSION_ACTIVE) {
155
+        if (session_status() != PHP_SESSION_ACTIVE) {
156 156
             session_start();
157 157
         }
158 158
         
159
-        if(!isset($_SESSION['localization_messages'])) {
159
+        if (!isset($_SESSION['localization_messages'])) {
160 160
             $_SESSION['localization_messages'] = array();
161 161
         }
162 162
     }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     {
174 174
         $this->sources = Localization::getSources();
175 175
         
176
-        if(empty($this->sources)) 
176
+        if (empty($this->sources)) 
177 177
         {
178 178
             throw new Localization_Exception(
179 179
                 'Cannot start editor: no sources defined.',
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         }
184 184
         
185 185
         $activeID = $this->request->registerParam($this->getVarName('source'))->setEnum(Localization::getSourceIDs())->get();
186
-        if(empty($activeID)) {
186
+        if (empty($activeID)) {
187 187
             $activeID = $this->getDefaultSourceID();
188 188
         }
189 189
         
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     protected function getDefaultSourceID() : string
194 194
     {
195 195
         $default = $this->getOption('default-source');
196
-        if(!empty($default) && Localization::sourceAliasExists($default)) {
196
+        if (!empty($default) && Localization::sourceAliasExists($default)) {
197 197
             return Localization::getSourceByAlias($default)->getID();
198 198
         }
199 199
         
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
         $names = array();
206 206
         
207 207
         $locales = Localization::getAppLocales();
208
-        foreach($locales as $locale) {
209
-            if(!$locale->isNative()) {
208
+        foreach ($locales as $locale) {
209
+            if (!$locale->isNative()) {
210 210
                 $this->appLocales[] = $locale;
211 211
                 $names[] = $locale->getName();
212 212
             }
213 213
         }
214 214
         
215 215
         // use the default locale if no other is available.
216
-        if(empty($names)) {
216
+        if (empty($names)) {
217 217
             $this->activeAppLocale = Localization::getAppLocale();
218 218
             return;
219 219
         }
220 220
        
221 221
         $activeID = $this->request->registerParam($this->getVarName('locale'))->setEnum($names)->get();
222
-        if(empty($activeID)) {
222
+        if (empty($activeID)) {
223 223
             $activeID = $this->appLocales[0]->getName();
224 224
         }
225 225
         
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
         
235 235
         $this->filters = new Localization_Editor_Filters($this);
236 236
         
237
-        if($this->request->getBool($this->getVarName('scan'))) 
237
+        if ($this->request->getBool($this->getVarName('scan'))) 
238 238
         {
239 239
             $this->executeScan();
240 240
         } 
241
-        else if($this->request->getBool($this->getVarName('save'))) 
241
+        else if ($this->request->getBool($this->getVarName('save'))) 
242 242
         {
243 243
             $this->executeSave();
244 244
         }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             </button>
286 286
             <div class="collapse navbar-collapse" id="navbarsExampleDefault">
287 287
                 <?php 
288
-                    if(!empty($this->appLocales))
288
+                    if (!empty($this->appLocales))
289 289
                     {
290 290
                         ?>
291 291
                             <ul class="navbar-nav mr-auto">
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
                                 	</a>
296 296
                                     <div class="dropdown-menu" aria-labelledby="dropdown01">
297 297
                                     	<?php 
298
-                                    	    foreach($this->sources as $source)
298
+                                    	    foreach ($this->sources as $source)
299 299
                                     	    {
300 300
                                     	       ?>
301 301
                                         			<a class="dropdown-item" href="<?php echo $this->getSourceURL($source) ?>">
302 302
                                         				<?php 
303
-                                            				if($source->getID() === $this->activeSource->getID()) 
303
+                                            				if ($source->getID() === $this->activeSource->getID()) 
304 304
                                             				{
305 305
                                             				    ?>
306 306
                                             				    	<b><?php echo $source->getLabel() ?></b>
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                                         				?>
314 314
                                         				<?php
315 315
                                         				    $untranslated = $source->countUntranslated($this->scanner);
316
-                                        				    if($untranslated > 0) {
316
+                                        				    if ($untranslated > 0) {
317 317
                                         				        ?>
318 318
                                         				        	(<span class="text-danger" title="<?php ptex('%1$s texts have not been translated in this text source.', 'Amount of texts', $untranslated) ?>"><?php echo $untranslated ?></span>)
319 319
                                 				            	<?php 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                                 	</a>
332 332
                                     <div class="dropdown-menu" aria-labelledby="dropdown01">
333 333
                                     	<?php 
334
-                                    	    foreach($this->appLocales as $locale)
334
+                                    	    foreach ($this->appLocales as $locale)
335 335
                                     	    {
336 336
                                     	       ?>
337 337
                                         			<a class="dropdown-item" href="<?php echo $this->getLocaleURL($locale) ?>">
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                                     </a>
350 350
                     			</li>
351 351
                     			<?php 
352
-                        			if($this->scanner->hasWarnings()) {
352
+                        			if ($this->scanner->hasWarnings()) {
353 353
                         			    ?>
354 354
                         			    	<li class="nav-item">
355 355
                         			    		<a href="<?php echo $this->getWarningsURL() ?>">
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                 ?>
369 369
                 <?php 
370 370
                     $backURL = $this->getOption('back-url');
371
-                    if(!empty($backURL)) 
371
+                    if (!empty($backURL)) 
372 372
                     {
373 373
                         ?>
374 374
                             <a href="<?php echo $backURL ?>" class="btn btn-light btn-sm">
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 		<main role="main" class="container">
384 384
 			<div>
385 385
     			<?php 
386
-    			    if(empty($this->appLocales))
386
+    			    if (empty($this->appLocales))
387 387
     			    {
388 388
     			        ?>
389 389
     			        	<div class="alert alert-danger">
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     			        	</div>
394 394
     			        <?php 
395 395
     			    }
396
-    			    else if($this->request->getBool($this->getVarName('warnings')))
396
+    			    else if ($this->request->getBool($this->getVarName('warnings')))
397 397
     			    {
398 398
     			        echo $this->renderWarnings();
399 399
     			    }
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
     			        ?>
403 403
             				<h1><?php echo $this->activeSource->getLabel() ?></h1>
404 404
             				<?php 
405
-                				if(!empty($_SESSION['localization_messages'])) 
405
+                				if (!empty($_SESSION['localization_messages'])) 
406 406
                 				{
407
-                				    foreach($_SESSION['localization_messages'] as $def)
407
+                				    foreach ($_SESSION['localization_messages'] as $def)
408 408
                 				    {
409 409
                 				        ?>
410 410
                 				        	<div class="alert alert-<?php echo $def['type'] ?>" role="alert">
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             				</p>
434 434
             				<br>
435 435
             				<?php
436
-                				if(!$this->scanner->isScanAvailable()) 
436
+                				if (!$this->scanner->isScanAvailable()) 
437 437
                 				{
438 438
                 				    ?>
439 439
                 				    	<div class="alert alert-primary" role="alert">
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
         		<?php 
481 481
         		    $warnings = $this->scanner->getWarnings();
482 482
         		    
483
-        		    foreach($warnings as $warning)
483
+        		    foreach ($warnings as $warning)
484 484
         		    {
485 485
         		        ?>
486 486
         		        	<dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt>
@@ -504,9 +504,9 @@  discard block
 block discarded – undo
504 504
         
505 505
         $result = array();
506 506
         
507
-        foreach($strings as $string)
507
+        foreach ($strings as $string)
508 508
         {
509
-            if($this->filters->isStringMatch($string)) {
509
+            if ($this->filters->isStringMatch($string)) {
510 510
                 $result[] = $string;
511 511
             }
512 512
         }
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     {
538 538
         $strings = $this->getFilteredStrings();
539 539
         
540
-        if(empty($strings))
540
+        if (empty($strings))
541 541
         {
542 542
             ?>
543 543
             	<div class="alert alert-info">
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 				<div class="form-hiddens">
560 560
 					<?php 
561 561
     					$params = $this->getRequestParams();
562
-    					foreach($params as $name => $value) {
562
+    					foreach ($params as $name => $value) {
563 563
     					    ?>
564 564
     					    	<input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>">
565 565
     					    <?php 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
     				</thead>
578 578
     				<tbody>
579 579
     					<?php 
580
-    					    foreach($keep as $string)
580
+    					    foreach ($keep as $string)
581 581
     					    {
582 582
     					        $this->renderListEntry($string);
583 583
     					    }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
     				</tbody>
586 586
     			</table>
587 587
     			<?php 
588
-        			if($pager->hasPages()) 
588
+        			if ($pager->hasPages()) 
589 589
         			{
590 590
         			    $prevUrl = $this->getPaginationURL($pager->getPreviousPage());
591 591
         			    $nextUrl = $this->getPaginationURL($pager->getNextPage());
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
                             		</li>
601 601
                             		<?php 
602 602
                             		    $numbers = $pager->getPageNumbers();
603
-                            		    foreach($numbers as $number) 
603
+                            		    foreach ($numbers as $number) 
604 604
                             		    {
605 605
                             		        $url = $this->getPaginationURL($number);
606 606
                             		        
607 607
                             		        ?>
608
-                            		        	<li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>">
608
+                            		        	<li class="page-item <?php if ($pager->isCurrentPage($number)) { echo 'active'; } ?>">
609 609
                             		        		<a class="page-link" href="<?php echo $url ?>">
610 610
                             		        			<?php echo $number ?>
611 611
                         		        			</a>
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
         <?php 
636 636
     }
637 637
     
638
-    protected function getPaginationURL(int $page, array $params=array()) : string
638
+    protected function getPaginationURL(int $page, array $params = array()) : string
639 639
     {
640 640
         $params[$this->getVarName('page')] = $page;
641 641
         
@@ -648,11 +648,11 @@  discard block
 block discarded – undo
648 648
         $text = $string->getText();
649 649
         
650 650
         $previewText = $string->getTranslatedText();
651
-        if(empty($previewText)) {
651
+        if (empty($previewText)) {
652 652
             $previewText = $text->getText();
653 653
         }
654 654
         
655
-        $shortText =  $this->renderText($previewText, 50);
655
+        $shortText = $this->renderText($previewText, 50);
656 656
         
657 657
         $files = $string->getFiles();
658 658
         
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
         			</p>
673 673
                     <?php
674 674
                         $explanation = $text->getExplanation();
675
-                        if(!empty($explanation))
675
+                        if (!empty($explanation))
676 676
                         {
677 677
                             ?>
678 678
                             <p>
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
             				<?php 
696 696
             				    $totalFiles = count($files);
697 697
             				    
698
-            				    if($totalFiles == 1)
698
+            				    if ($totalFiles == 1)
699 699
             				    {
700 700
             				        pt('Found in a single file:');
701 701
             				    }
@@ -710,16 +710,16 @@  discard block
 block discarded – undo
710 710
                 				<?php 
711 711
                 				    $locations = $string->getStrings();
712 712
                 				    
713
-                    				foreach($locations as $location) 
713
+                    				foreach ($locations as $location) 
714 714
                     				{
715 715
                     				    $file = $location->getSourceFile();
716 716
                     				    $line = $location->getLine();
717 717
                     				    
718 718
                     				    $ext = FileHelper::getExtension($file);
719 719
                     				    
720
-                    				    if($ext == 'php') {
720
+                    				    if ($ext == 'php') {
721 721
                     				        $icon = 'fab fa-php';
722
-                    				    } else if($ext == 'js') {
722
+                    				    } else if ($ext == 'js') {
723 723
                     				        $icon = 'fab fa-js-square';
724 724
                     				    } else {
725 725
                     				        $icon = 'fas fa-file-code';
@@ -741,13 +741,13 @@  discard block
 block discarded – undo
741 741
         <?php 
742 742
     }
743 743
     
744
-    protected function renderText(string $text, int $cutAt=0) : string
744
+    protected function renderText(string $text, int $cutAt = 0) : string
745 745
     {
746
-        if(empty($text)) {
746
+        if (empty($text)) {
747 747
             return '';
748 748
         }
749 749
 
750
-        if($cutAt > 0) {
750
+        if ($cutAt > 0) {
751 751
             $text = ConvertHelper::text_cut($text, $cutAt);
752 752
         }
753 753
 
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
         
756 756
         $vars = $this->detectVariables($text);
757 757
         
758
-        foreach($vars as $var) {
758
+        foreach ($vars as $var) {
759 759
             $text = str_replace($var, '<span class="placeholder">'.$var.'</span>', $text);
760 760
         }
761 761
         
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
         $result = array();
768 768
         preg_match_all('/%[0-9]+d|%s|%[0-9]+\$s/i', $string, $result, PREG_PATTERN_ORDER);
769 769
 
770
-        if(isset($result[0]) && !empty($result[0])) {
770
+        if (isset($result[0]) && !empty($result[0])) {
771 771
             return $result[0];
772 772
         }
773 773
         
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
         
784 784
         // add a counter of the additional files if the total
785 785
         // is higher than the maximum to show
786
-        if($total > $max) 
786
+        if ($total > $max) 
787 787
         {
788 788
             $length = $max;
789
-            if($length > $keepTotal) {
789
+            if ($length > $keepTotal) {
790 790
                 $length = $keepTotal; 
791 791
             }
792 792
             
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
         return FileHelper::readContents($this->installPath.'/css/editor.css');
815 815
     }
816 816
     
817
-    public function getSourceURL(Localization_Source $source, array $params=array()) : string
817
+    public function getSourceURL(Localization_Source $source, array $params = array()) : string
818 818
     {
819 819
         $params[$this->getVarName('source')] = $source->getID();
820 820
         
821 821
         return $this->getURL($params);
822 822
     }
823 823
     
824
-    public function getLocaleURL(Localization_Locale $locale, array $params=array()) : string
824
+    public function getLocaleURL(Localization_Locale $locale, array $params = array()) : string
825 825
     {
826 826
         $params[$this->getVarName('locale')] = $locale->getName();
827 827
         
@@ -838,12 +838,12 @@  discard block
 block discarded – undo
838 838
         return $this->getSourceURL($this->activeSource, array($this->getVarName('warnings') => 'yes'));
839 839
     }
840 840
     
841
-    public function getURL(array $params=array()) : string
841
+    public function getURL(array $params = array()) : string
842 842
     {
843 843
         $persist = $this->getRequestParams();
844 844
         
845
-        foreach($persist as $name => $value) {
846
-            if(!isset($params[$name])) {
845
+        foreach ($persist as $name => $value) {
846
+            if (!isset($params[$name])) {
847 847
                 $params[$name] = $value;
848 848
             }
849 849
         }
@@ -880,11 +880,11 @@  discard block
 block discarded – undo
880 880
         $translator = Localization::getTranslator($this->activeAppLocale);
881 881
         
882 882
         $strings = $data[$this->getVarName('strings')];
883
-        foreach($strings as $hash => $text) 
883
+        foreach ($strings as $hash => $text) 
884 884
         {
885 885
             $text = trim($text);
886 886
             
887
-            if(empty($text)) {
887
+            if (empty($text)) {
888 888
                 continue;
889 889
             } 
890 890
             
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
     
907 907
     protected function renderStatus(Localization_Scanner_StringHash $hash) : string
908 908
     {
909
-        if($hash->isTranslated()) {
909
+        if ($hash->isTranslated()) {
910 910
             return '<i class="fa fa-check text-success"></i>';
911 911
         }        
912 912
         
@@ -917,18 +917,18 @@  discard block
 block discarded – undo
917 917
     {
918 918
         $types = array();
919 919
         
920
-        if($hash->hasLanguageType('PHP')) {
920
+        if ($hash->hasLanguageType('PHP')) {
921 921
             $types[] = t('Server');
922 922
         }
923 923
         
924
-        if($hash->hasLanguageType('Javascript')) {
924
+        if ($hash->hasLanguageType('Javascript')) {
925 925
             $types[] = t('Client');
926 926
         }
927 927
         
928 928
         return implode(', ', $types);
929 929
     }
930 930
     
931
-    protected function addMessage(string $message, string $type=self::MESSAGE_INFO) : void
931
+    protected function addMessage(string $message, string $type = self::MESSAGE_INFO) : void
932 932
     {
933 933
         $_SESSION['localization_messages'][] = array(
934 934
             'text' => $message,
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
     public function getAppName() : string
966 966
     {
967 967
         $name = $this->getOption('appname');
968
-        if(!empty($name)) {
968
+        if (!empty($name)) {
969 969
             return $name;
970 970
         }
971 971
         
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -237,8 +237,7 @@  discard block
 block discarded – undo
237 237
         if($this->request->getBool($this->getVarName('scan'))) 
238 238
         {
239 239
             $this->executeScan();
240
-        } 
241
-        else if($this->request->getBool($this->getVarName('save'))) 
240
+        } else if($this->request->getBool($this->getVarName('save'))) 
242 241
         {
243 242
             $this->executeSave();
244 243
         }
@@ -305,8 +304,7 @@  discard block
 block discarded – undo
305 304
                                             				    ?>
306 305
                                             				    	<b><?php echo $source->getLabel() ?></b>
307 306
                                         				    	<?php 
308
-                                            				}
309
-                                            				else
307
+                                            				} else
310 308
                                             				{
311 309
                                             				    echo $source->getLabel();
312 310
                                             				}
@@ -392,12 +390,10 @@  discard block
 block discarded – undo
392 390
     			        		<?php pt('No application locales were added to translate to.') ?>
393 391
     			        	</div>
394 392
     			        <?php 
395
-    			    }
396
-    			    else if($this->request->getBool($this->getVarName('warnings')))
393
+    			    } else if($this->request->getBool($this->getVarName('warnings')))
397 394
     			    {
398 395
     			        echo $this->renderWarnings();
399
-    			    }
400
-    			    else
396
+    			    } else
401 397
     			    {
402 398
     			        ?>
403 399
             				<h1><?php echo $this->activeSource->getLabel() ?></h1>
@@ -447,8 +443,7 @@  discard block
 block discarded – undo
447 443
                                             </a>
448 444
                                         </p>
449 445
                 				    <?php 
450
-                				}
451
-                				else
446
+                				} else
452 447
                 				{
453 448
                 				    echo $this->filters->renderForm();
454 449
 
@@ -698,8 +693,7 @@  discard block
 block discarded – undo
698 693
             				    if($totalFiles == 1)
699 694
             				    {
700 695
             				        pt('Found in a single file:');
701
-            				    }
702
-            				    else
696
+            				    } else
703 697
             				    {
704 698
             				        pt('Found in %1$s files:', $totalFiles);
705 699
             				    }
Please login to merge, or discard this patch.
src/Localization.php 3 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
     const EVENT_LOCALE_CHANGED = 'LocaleChanged';
54 54
 
55 55
     /**
56
-    * Collection of all locales by namespace (application, content, custom...). 
57
-    *
58
-    * @var array<string,array<string,Localization_Locale>>
59
-    * @see Localization::addLocale()
60
-    */
56
+     * Collection of all locales by namespace (application, content, custom...). 
57
+     *
58
+     * @var array<string,array<string,Localization_Locale>>
59
+     * @see Localization::addLocale()
60
+     */
61 61
     protected static $locales = array();
62 62
 
63 63
     /**
@@ -66,57 +66,57 @@  discard block
 block discarded – undo
66 66
      */
67 67
     private static $initDone = false;
68 68
 
69
-   /**
70
-    * Path to the file in which the scanner results are stored.
71
-    * @var string
72
-    * @see Localization::configure()
73
-    */
69
+    /**
70
+     * Path to the file in which the scanner results are stored.
71
+     * @var string
72
+     * @see Localization::configure()
73
+     */
74 74
     protected static $storageFile = '';
75 75
     
76
-   /**
77
-    * Path to the folder into which the client libraries are written.
78
-    * @var string
79
-    * @see Localization::setClientLibrariesFolder()
80
-    */
76
+    /**
77
+     * Path to the folder into which the client libraries are written.
78
+     * @var string
79
+     * @see Localization::setClientLibrariesFolder()
80
+     */
81 81
     protected static $clientFolder = '';
82 82
     
83
-   /**
84
-    * If this key changes, client libraries are refreshed.
85
-    * @var string
86
-    * @see Localization::setClientLibrariesCacheKey()
87
-    */
83
+    /**
84
+     * If this key changes, client libraries are refreshed.
85
+     * @var string
86
+     * @see Localization::setClientLibrariesCacheKey()
87
+     */
88 88
     protected static $clientCacheKey = '';
89 89
     
90
-   /**
91
-    * Whether the configuration has been made.
92
-    * @var bool
93
-    * @see Localization::configure()
94
-    */
90
+    /**
91
+     * Whether the configuration has been made.
92
+     * @var bool
93
+     * @see Localization::configure()
94
+     */
95 95
     protected static $configured = false;
96 96
     
97
-   /**
98
-    * Stores event listener instances.
99
-    * @var array
100
-    */
97
+    /**
98
+     * Stores event listener instances.
99
+     * @var array
100
+     */
101 101
     protected static $listeners = array();
102 102
     
103
-   /**
104
-    * @var integer
105
-    * @see Localization::addEventListener()
106
-    */
103
+    /**
104
+     * @var integer
105
+     * @see Localization::addEventListener()
106
+     */
107 107
     protected static $listenersCounter = 0;
108 108
     
109
-   /**
110
-    * @var Localization_Translator|NULL
111
-    */
109
+    /**
110
+     * @var Localization_Translator|NULL
111
+     */
112 112
     protected static $translator;
113 113
     
114
-   /**
115
-    * Initializes the localization layer. This is done
116
-    * automatically, and only once per request.
117
-    * 
118
-    * (Called at the end of this file)
119
-    */
114
+    /**
115
+     * Initializes the localization layer. This is done
116
+     * automatically, and only once per request.
117
+     * 
118
+     * (Called at the end of this file)
119
+     */
120 120
     public static function init() : void
121 121
     {
122 122
         if(self::$initDone) {
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
         return self::getLocalesByNS(self::NAMESPACE_APPLICATION);
156 156
     }
157 157
     
158
-   /**
159
-    * Retrieves all locales in the specified namespace.
160
-    * 
161
-    * @param string $namespace
162
-    * @return Localization_Locale[]
163
-    */
158
+    /**
159
+     * Retrieves all locales in the specified namespace.
160
+     * 
161
+     * @param string $namespace
162
+     * @return Localization_Locale[]
163
+     */
164 164
     public static function getLocalesByNS(string $namespace)
165 165
     {
166 166
         if(isset(self::$locales[$namespace])) {
@@ -177,35 +177,35 @@  discard block
 block discarded – undo
177 177
         );
178 178
     }
179 179
     
180
-   /**
181
-    * Adds an application locale to use in the application.
182
-    * 
183
-    * @param string $localeName
184
-    * @return Localization_Locale
185
-    */
180
+    /**
181
+     * Adds an application locale to use in the application.
182
+     * 
183
+     * @param string $localeName
184
+     * @return Localization_Locale
185
+     */
186 186
     public static function addAppLocale(string $localeName) : Localization_Locale
187 187
     {
188 188
         return self::addLocaleByNS($localeName, self::NAMESPACE_APPLICATION);
189 189
     }
190 190
     
191
-   /**
192
-    * Adds a content locale to use for content in the application.
193
-    * 
194
-    * @param string $localeName
195
-    * @return Localization_Locale
196
-    */
191
+    /**
192
+     * Adds a content locale to use for content in the application.
193
+     * 
194
+     * @param string $localeName
195
+     * @return Localization_Locale
196
+     */
197 197
     public static function addContentLocale(string $localeName) : Localization_Locale
198 198
     {
199 199
         return self::addLocaleByNS($localeName, self::NAMESPACE_CONTENT);
200 200
     }
201 201
     
202
-   /**
203
-    * Adds a locale to the specified namespace.
204
-    * 
205
-    * @param string $localeName
206
-    * @param string $namespace
207
-    * @return Localization_Locale
208
-    */
202
+    /**
203
+     * Adds a locale to the specified namespace.
204
+     * 
205
+     * @param string $localeName
206
+     * @param string $namespace
207
+     * @return Localization_Locale
208
+     */
209 209
     public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale
210 210
     {
211 211
         if(!isset(self::$locales[$namespace])) {
@@ -343,45 +343,45 @@  discard block
 block discarded – undo
343 343
         return self::getSelectedLocaleByNS(self::NAMESPACE_APPLICATION);
344 344
     }
345 345
     
346
-   /**
347
-    * Retrieves the name of the selected application locale.
348
-    * 
349
-    * @return string
350
-    */
346
+    /**
347
+     * Retrieves the name of the selected application locale.
348
+     * 
349
+     * @return string
350
+     */
351 351
     public static function getAppLocaleName() : string
352 352
     {
353 353
         return self::getLocaleNameByNS(self::NAMESPACE_APPLICATION);
354 354
     }
355 355
     
356
-   /**
357
-    * Retrieves the names of the available application locales.
358
-    * @return string[]
359
-    */
356
+    /**
357
+     * Retrieves the names of the available application locales.
358
+     * @return string[]
359
+     */
360 360
     public static function getAppLocaleNames() : array
361 361
     {
362 362
         return self::getLocaleNamesByNS(self::NAMESPACE_APPLICATION);
363 363
     }
364 364
     
365
-   /**
366
-    * Retrieves the selected locale name in the specified namespace.
367
-    * 
368
-    * @param string $namespace
369
-    * @throws Localization_Exception
370
-    * @return string
371
-    */
365
+    /**
366
+     * Retrieves the selected locale name in the specified namespace.
367
+     * 
368
+     * @param string $namespace
369
+     * @throws Localization_Exception
370
+     * @return string
371
+     */
372 372
     public static function getLocaleNameByNS(string $namespace) : string
373 373
     {
374 374
         return self::getSelectedLocaleByNS($namespace)->getName();
375 375
     }
376 376
     
377
-   /**
378
-    * Retrieves the selected locale instance for the specified namespace.
379
-    * 
380
-    * @param string $namespace
381
-    * @return Localization_Locale
382
-    * @throws Localization_Exception
383
-    * @see Localization::ERROR_NO_LOCALE_SELECTED_IN_NS
384
-    */
377
+    /**
378
+     * Retrieves the selected locale instance for the specified namespace.
379
+     * 
380
+     * @param string $namespace
381
+     * @return Localization_Locale
382
+     * @throws Localization_Exception
383
+     * @see Localization::ERROR_NO_LOCALE_SELECTED_IN_NS
384
+     */
385 385
     public static function getSelectedLocaleByNS(string $namespace) : Localization_Locale
386 386
     {
387 387
         self::requireNamespace($namespace);
@@ -400,24 +400,24 @@  discard block
 block discarded – undo
400 400
         );
401 401
     }
402 402
     
403
-   /**
404
-    * Stores the selected locale names by namespace.
405
-    * @var array<string,Localization_Locale>
406
-    */
403
+    /**
404
+     * Stores the selected locale names by namespace.
405
+     * @var array<string,Localization_Locale>
406
+     */
407 407
     protected static $selected = array();
408 408
 
409
-   /**
410
-    * Selects the active locale for the specified namespace.
411
-    *
412
-    * NOTE: Triggers the "LocaleChanged" event.
413
-    * 
414
-    * @param string $localeName
415
-    * @param string $namespace
416
-    * @return Localization_Locale
417
-    * @throws Localization_Exception
418
-    *
419
-    * @see Localization_Event_LocaleChanged
420
-    */
409
+    /**
410
+     * Selects the active locale for the specified namespace.
411
+     *
412
+     * NOTE: Triggers the "LocaleChanged" event.
413
+     * 
414
+     * @param string $localeName
415
+     * @param string $namespace
416
+     * @return Localization_Locale
417
+     * @throws Localization_Exception
418
+     *
419
+     * @see Localization_Event_LocaleChanged
420
+     */
421 421
     public static function selectLocaleByNS(string $localeName, string $namespace) : Localization_Locale
422 422
     {
423 423
         self::requireNamespace($namespace);
@@ -548,15 +548,15 @@  discard block
 block discarded – undo
548 548
         return self::selectLocaleByNS($localeName, self::NAMESPACE_APPLICATION);
549 549
     }
550 550
 
551
-   /**
552
-    * Retrieves an application locale by its name. 
553
-    * Note that the locale must have been added first.
554
-    * 
555
-    * @param string $localeName
556
-    * @throws Localization_Exception
557
-    * @return Localization_Locale
558
-    * @see Localization::appLocaleExists()
559
-    */
551
+    /**
552
+     * Retrieves an application locale by its name. 
553
+     * Note that the locale must have been added first.
554
+     * 
555
+     * @param string $localeName
556
+     * @throws Localization_Exception
557
+     * @return Localization_Locale
558
+     * @see Localization::appLocaleExists()
559
+     */
560 560
     public static function getAppLocaleByName(string $localeName) : Localization_Locale
561 561
     {
562 562
         return self::getLocaleByNameNS($localeName, self::NAMESPACE_APPLICATION);
@@ -591,10 +591,10 @@  discard block
 block discarded – undo
591 591
         return self::getLocalesByNS(self::NAMESPACE_CONTENT);
592 592
     }
593 593
     
594
-   /**
595
-    * Retrieves the names of all content locales that have been added.
596
-    * @return string[]
597
-    */
594
+    /**
595
+     * Retrieves the names of all content locales that have been added.
596
+     * @return string[]
597
+     */
598 598
     public static function getContentLocaleNames()
599 599
     {
600 600
         return self::getLocaleNamesByNS(self::NAMESPACE_CONTENT);
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
         sort($names);
618 618
         
619 619
         return $names;
620
-     }
620
+        }
621 621
     
622 622
     /**
623 623
      * Checks by the locale name if the specified locale is
@@ -646,14 +646,14 @@  discard block
 block discarded – undo
646 646
         return self::getLocaleByNameNS($localeName, self::NAMESPACE_CONTENT);
647 647
     }
648 648
     
649
-   /**
650
-    * Retrieves a locale by its name in the specified namespace.
651
-    * 
652
-    * @param string $localeName
653
-    * @param string $namespace
654
-    * @throws Localization_Exception
655
-    * @return Localization_Locale
656
-    */
649
+    /**
650
+     * Retrieves a locale by its name in the specified namespace.
651
+     * 
652
+     * @param string $localeName
653
+     * @param string $namespace
654
+     * @throws Localization_Exception
655
+     * @return Localization_Locale
656
+     */
657 657
     public static function getLocaleByNameNS(string $localeName, string $namespace) : Localization_Locale
658 658
     {
659 659
         self::requireNamespace($namespace);
@@ -724,10 +724,10 @@  discard block
 block discarded – undo
724 724
         return self::selectLocaleByNS($localeName, self::NAMESPACE_CONTENT);
725 725
     }
726 726
     
727
-   /**
728
-    * Checks whether the localization has been configured entirely.
729
-    * @return bool
730
-    */
727
+    /**
728
+     * Checks whether the localization has been configured entirely.
729
+     * @return bool
730
+     */
731 731
     public static function isConfigured() : bool
732 732
     {
733 733
         return self::$configured;
@@ -799,29 +799,29 @@  discard block
 block discarded – undo
799 799
         );
800 800
     }
801 801
     
802
-   /**
803
-    * Injects a content locales selector element into the specified
804
-    * HTML QuickForm2 container.
805
-    * 
806
-    * @param string $elementName
807
-    * @param HTML_QuickForm2_Container $container
808
-    * @param string $label
809
-    * @return HTML_QuickForm2_Element_Select
810
-    */
802
+    /**
803
+     * Injects a content locales selector element into the specified
804
+     * HTML QuickForm2 container.
805
+     * 
806
+     * @param string $elementName
807
+     * @param HTML_QuickForm2_Container $container
808
+     * @param string $label
809
+     * @return HTML_QuickForm2_Element_Select
810
+     */
811 811
     public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
812 812
     {
813 813
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label);
814 814
     }
815 815
     
816
-   /**
817
-    * Injects an app locales selector element into the specified
816
+    /**
817
+     * Injects an app locales selector element into the specified
818 818
      * HTML QuickForm2 container.
819 819
      * 
820
-    * @param string $elementName
821
-    * @param HTML_QuickForm2_Container $container
822
-    * @param string $label
823
-    * @return HTML_QuickForm2_Element_Select
824
-    */
820
+     * @param string $elementName
821
+     * @param HTML_QuickForm2_Container $container
822
+     * @param string $label
823
+     * @return HTML_QuickForm2_Element_Select
824
+     */
825 825
     public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
826 826
     {
827 827
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label);
@@ -857,26 +857,26 @@  discard block
 block discarded – undo
857 857
         return $select;
858 858
     }
859 859
 
860
-   /**
861
-    * @var Localization_Source[]
862
-    */
860
+    /**
861
+     * @var Localization_Source[]
862
+     */
863 863
     protected static $sources = array();
864 864
     
865
-   /**
866
-    * @var string[]
867
-    */
865
+    /**
866
+     * @var string[]
867
+     */
868 868
     protected static $excludeFolders = array();
869 869
     
870
-   /**
871
-    * @var string[]
872
-    */
870
+    /**
871
+     * @var string[]
872
+     */
873 873
     protected static $excludeFiles = array();
874 874
     
875
-   /**
876
-    * Retrieves all currently available sources.
877
-    * 
878
-    * @return Localization_Source[]
879
-    */
875
+    /**
876
+     * Retrieves all currently available sources.
877
+     * 
878
+     * @return Localization_Source[]
879
+     */
880 880
     public static function getSources() : array
881 881
     {
882 882
         return self::$sources;
@@ -908,10 +908,10 @@  discard block
 block discarded – undo
908 908
         return $source;
909 909
     }
910 910
     
911
-   /**
912
-    * Retrieves all sources grouped by their group name.
913
-    * @return array
914
-    */
911
+    /**
912
+     * Retrieves all sources grouped by their group name.
913
+     * @return array
914
+     */
915 915
     public static function getSourcesGrouped()
916 916
     {
917 917
         $sources = self::getSources();
@@ -932,11 +932,11 @@  discard block
 block discarded – undo
932 932
         return $grouped;
933 933
     }
934 934
     
935
-   /**
936
-    * Checks whether a specific source exists by its ID.
937
-    * @param string $sourceID
938
-    * @return boolean
939
-    */
935
+    /**
936
+     * Checks whether a specific source exists by its ID.
937
+     * @param string $sourceID
938
+     * @return boolean
939
+     */
940 940
     public static function sourceExists(string $sourceID) : bool
941 941
     {
942 942
         $sources = self::getSources();
@@ -949,11 +949,11 @@  discard block
 block discarded – undo
949 949
         return false;
950 950
     }
951 951
     
952
-   /**
953
-    * Checks whether a specific source exists by its alias.
954
-    * @param string $sourceAlias
955
-    * @return boolean
956
-    */
952
+    /**
953
+     * Checks whether a specific source exists by its alias.
954
+     * @param string $sourceAlias
955
+     * @return boolean
956
+     */
957 957
     public static function sourceAliasExists(string $sourceAlias) : bool
958 958
     {
959 959
         $sources = self::getSources();
@@ -966,13 +966,13 @@  discard block
 block discarded – undo
966 966
         return false;
967 967
     }
968 968
 
969
-   /**
970
-    * Retrieves a localization source by its ID.
971
-    * 
972
-    * @param string $sourceID
973
-    * @throws Localization_Exception
974
-    * @return Localization_Source
975
-    */
969
+    /**
970
+     * Retrieves a localization source by its ID.
971
+     * 
972
+     * @param string $sourceID
973
+     * @throws Localization_Exception
974
+     * @return Localization_Source
975
+     */
976 976
     public static function getSourceByID(string $sourceID) : Localization_Source
977 977
     {
978 978
         $sources = self::getSources();
@@ -1062,17 +1062,17 @@  discard block
 block discarded – undo
1062 1062
         }
1063 1063
     }
1064 1064
     
1065
-   /**
1066
-    * Sets a key that is used to verify whether the client
1067
-    * libraries have to be refreshed. A common use is to set
1068
-    * this to the application's version number to guarantee
1069
-    * new texts are automatically used with each release.
1070
-    * 
1071
-    * NOTE: Otherwise files are refreshed only when saving 
1072
-    * them in the editor UI.
1073
-    *  
1074
-    * @param string $key
1075
-    */
1065
+    /**
1066
+     * Sets a key that is used to verify whether the client
1067
+     * libraries have to be refreshed. A common use is to set
1068
+     * this to the application's version number to guarantee
1069
+     * new texts are automatically used with each release.
1070
+     * 
1071
+     * NOTE: Otherwise files are refreshed only when saving 
1072
+     * them in the editor UI.
1073
+     *  
1074
+     * @param string $key
1075
+     */
1076 1076
     public static function setClientLibrariesCacheKey(string $key) : void
1077 1077
     {
1078 1078
         self::$clientCacheKey = $key;
@@ -1083,23 +1083,23 @@  discard block
 block discarded – undo
1083 1083
         return self::$clientCacheKey;
1084 1084
     }
1085 1085
     
1086
-   /**
1087
-    * Sets the folder where client libraries are to be stored.
1088
-    * @param string $folder
1089
-    */
1086
+    /**
1087
+     * Sets the folder where client libraries are to be stored.
1088
+     * @param string $folder
1089
+     */
1090 1090
     public static function setClientLibrariesFolder(string $folder) : void
1091 1091
     {
1092 1092
         self::$clientFolder = $folder;
1093 1093
     }
1094 1094
     
1095
-   /**
1096
-    * Retrieves the path to the folder in which the client
1097
-    * libraries should be stored.
1098
-    * 
1099
-    * NOTE: Can return an empty string, when this is disabled.
1100
-    * 
1101
-    * @return string
1102
-    */
1095
+    /**
1096
+     * Retrieves the path to the folder in which the client
1097
+     * libraries should be stored.
1098
+     * 
1099
+     * NOTE: Can return an empty string, when this is disabled.
1100
+     * 
1101
+     * @return string
1102
+     */
1103 1103
     public static function getClientLibrariesFolder() : string
1104 1104
     {
1105 1105
         return self::$clientFolder;
@@ -1119,13 +1119,13 @@  discard block
 block discarded – undo
1119 1119
         self::createGenerator()->writeFiles($force);
1120 1120
     }
1121 1121
     
1122
-   /**
1123
-    * Creates a new instance of the client generator class
1124
-    * that is used to write the localization files into the
1125
-    * target folder on disk.
1126
-    * 
1127
-    * @return Localization_ClientGenerator
1128
-    */
1122
+    /**
1123
+     * Creates a new instance of the client generator class
1124
+     * that is used to write the localization files into the
1125
+     * target folder on disk.
1126
+     * 
1127
+     * @return Localization_ClientGenerator
1128
+     */
1129 1129
     public static function createGenerator() : Localization_ClientGenerator
1130 1130
     {
1131 1131
         return new Localization_ClientGenerator();
@@ -1190,10 +1190,10 @@  discard block
 block discarded – undo
1190 1190
         return new Localization_Editor();
1191 1191
     }
1192 1192
     
1193
-   /**
1194
-    * Retrieves a list of all available source IDs.
1195
-    * @return string[]
1196
-    */
1193
+    /**
1194
+     * Retrieves a list of all available source IDs.
1195
+     * @return string[]
1196
+     */
1197 1197
     public static function getSourceIDs() : array
1198 1198
     {
1199 1199
         $ids = array();
@@ -1220,9 +1220,9 @@  discard block
 block discarded – undo
1220 1220
         return $aliases;
1221 1221
     }
1222 1222
     
1223
-   /**
1224
-    * Resets all locales to the built-in locale.
1225
-    */
1223
+    /**
1224
+     * Resets all locales to the built-in locale.
1225
+     */
1226 1226
     public static function reset() : void
1227 1227
     {
1228 1228
         self::$locales = array();
@@ -1260,12 +1260,12 @@  discard block
 block discarded – undo
1260 1260
         return self::$supportedLocales;
1261 1261
     }
1262 1262
     
1263
-   /**
1264
-    * Checks whether the specified locale is supported.
1265
-    * 
1266
-    * @param string $localeName
1267
-    * @return bool
1268
-    */
1263
+    /**
1264
+     * Checks whether the specified locale is supported.
1265
+     * 
1266
+     * @param string $localeName
1267
+     * @return bool
1268
+     */
1269 1269
     public static function isLocaleSupported(string $localeName) : bool
1270 1270
     {
1271 1271
         return file_exists(__DIR__.'/Localization/Locale/'.$localeName.'.php');
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     */
120 120
     public static function init() : void
121 121
     {
122
-        if(self::$initDone) {
122
+        if (self::$initDone) {
123 123
             return;
124 124
         }
125 125
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     */
164 164
     public static function getLocalesByNS(string $namespace)
165 165
     {
166
-        if(isset(self::$locales[$namespace])) {
166
+        if (isset(self::$locales[$namespace])) {
167 167
             return array_values(self::$locales[$namespace]);
168 168
         }
169 169
         
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
     */
209 209
     public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale
210 210
     {
211
-        if(!isset(self::$locales[$namespace])) {
211
+        if (!isset(self::$locales[$namespace])) {
212 212
             self::$locales[$namespace] = array();
213 213
         }
214 214
         
215
-        if(!isset(self::$locales[$namespace][$localeName])) 
215
+        if (!isset(self::$locales[$namespace][$localeName])) 
216 216
         {
217 217
             self::$locales[$namespace][$localeName] = self::createLocale($localeName);
218 218
             
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
      */
275 275
     public static function createCountry(string $id) : Localization_Country
276 276
     {
277
-        $className = Localization_Country::class.'_' . strtoupper($id);
277
+        $className = Localization_Country::class.'_'.strtoupper($id);
278 278
 
279 279
         $country = new $className();
280 280
 
281
-        if($country instanceof Localization_Country)
281
+        if ($country instanceof Localization_Country)
282 282
         {
283 283
             return $country;
284 284
         }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     {
387 387
         self::requireNamespace($namespace);
388 388
         
389
-        if(isset(self::$selected[$namespace])) {
389
+        if (isset(self::$selected[$namespace])) {
390 390
             return self::$selected[$namespace];
391 391
         }
392 392
         
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
         $locale = self::addLocaleByNS($localeName, $namespace);
426 426
         $previous = null;
427 427
         
428
-        if(isset(self::$selected[$namespace])) 
428
+        if (isset(self::$selected[$namespace])) 
429 429
         {
430
-            if(self::$selected[$namespace]->getName() === $localeName) {
430
+            if (self::$selected[$namespace]->getName() === $localeName) {
431 431
                 return $locale;
432 432
             }
433 433
             
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
         $class = Localization_Event::class.'_'.$name;
464 464
         $event = new $class($argsList);
465 465
         
466
-        if(!isset(self::$listeners[$name])) {
466
+        if (!isset(self::$listeners[$name])) {
467 467
             return $event;
468 468
         }
469 469
         
470
-        foreach(self::$listeners[$name] as $listener) 
470
+        foreach (self::$listeners[$name] as $listener) 
471 471
         {
472 472
             $callArgs = $listener['args'];
473 473
             array_unshift($callArgs, $event);
@@ -489,15 +489,15 @@  discard block
 block discarded – undo
489 489
      * @throws Localization_Exception
490 490
      * @see Localization::ERROR_UNKNOWN_EVENT_NAME
491 491
      */
492
-    public static function addEventListener(string $eventName, $callback, array $args=array()) : int
492
+    public static function addEventListener(string $eventName, $callback, array $args = array()) : int
493 493
     {
494
-        if(!isset(self::$listeners[$eventName])) {
494
+        if (!isset(self::$listeners[$eventName])) {
495 495
             self::$listeners[$eventName] = array();
496 496
         }
497 497
         
498 498
         $className = Localization_Event::class.'_'.$eventName;
499 499
         
500
-        if(!class_exists($className)) 
500
+        if (!class_exists($className)) 
501 501
         {
502 502
             throw new Localization_Exception(
503 503
                 sprintf('Unknown localization event [%s].', $eventName),
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
      * @throws Localization_Exception
532 532
      * @see Localization_Event_LocaleChanged
533 533
      */
534
-    public static function onLocaleChanged($callback, array $args=array()) : int
534
+    public static function onLocaleChanged($callback, array $args = array()) : int
535 535
     {
536 536
         return self::addEventListener(self::EVENT_LOCALE_CHANGED, $callback, $args);
537 537
     }
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
     {
659 659
         self::requireNamespace($namespace);
660 660
         
661
-        if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) {
661
+        if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) {
662 662
             return self::$locales[$namespace][$localeName];
663 663
         }
664 664
         
@@ -737,9 +737,9 @@  discard block
 block discarded – undo
737 737
      * @param Localization_Locale|null $locale
738 738
      * @return Localization_Translator
739 739
      */
740
-    public static function getTranslator(?Localization_Locale $locale=null) : Localization_Translator
740
+    public static function getTranslator(?Localization_Locale $locale = null) : Localization_Translator
741 741
     {
742
-        if($locale !== null)
742
+        if ($locale !== null)
743 743
         {
744 744
             $obj = new Localization_Translator();
745 745
             $obj->addSources(self::getSources());
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
             return $obj;
748 748
         }
749 749
             
750
-        if(!isset(self::$translator)) 
750
+        if (!isset(self::$translator)) 
751 751
         {
752 752
             $obj = new Localization_Translator();
753 753
             $obj->addSources(self::getSources());
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
     {
773 773
         self::requireNamespace($namespace);
774 774
         
775
-        if(isset(self::$locales[$namespace])) {
775
+        if (isset(self::$locales[$namespace])) {
776 776
             return count(self::$locales[$namespace]);
777 777
         }
778 778
         
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
      */
786 786
     protected static function requireNamespace(string $namespace) : void
787 787
     {
788
-        if(isset(self::$locales[$namespace])) {
788
+        if (isset(self::$locales[$namespace])) {
789 789
             return;
790 790
         }
791 791
         
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
     * @param string $label
809 809
     * @return HTML_QuickForm2_Element_Select
810 810
     */
811
-    public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
811
+    public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
812 812
     {
813 813
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label);
814 814
     }
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
     * @param string $label
823 823
     * @return HTML_QuickForm2_Element_Select
824 824
     */
825
-    public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
825
+    public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
826 826
     {
827 827
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label);
828 828
     }
@@ -839,9 +839,9 @@  discard block
 block discarded – undo
839 839
      * @return HTML_QuickForm2_Element_Select
840 840
      * @throws Localization_Exception
841 841
      */
842
-    public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
842
+    public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
843 843
     {
844
-        if(empty($label)) {
844
+        if (empty($label)) {
845 845
             $label = t('Language');
846 846
         }
847 847
 
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 
851 851
         $locales = self::getLocalesByNS($namespace);
852 852
         
853
-        foreach($locales as $locale) {
853
+        foreach ($locales as $locale) {
854 854
             $select->addOption($locale->getLabel(), $locale->getName());
855 855
         }
856 856
 
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
     
885 885
     public static function addExcludeFolder(string $folderName) : void
886 886
     { 
887
-        if(!in_array($folderName, self::$excludeFolders)) {
887
+        if (!in_array($folderName, self::$excludeFolders)) {
888 888
             self::$excludeFolders[] = $folderName;
889 889
         }
890 890
     }
891 891
     
892 892
     public static function addExcludeFile(string $fileName) : void
893 893
     {
894
-        if(!in_array($fileName, self::$excludeFiles)) {
894
+        if (!in_array($fileName, self::$excludeFiles)) {
895 895
             self::$excludeFiles[] = $fileName;
896 896
         }
897 897
     }
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
         
919 919
         $grouped = array();
920 920
         
921
-        foreach($sources as $source) 
921
+        foreach ($sources as $source) 
922 922
         {
923 923
             $group = $source->getGroup();
924 924
             
925
-            if(!isset($grouped[$group])) {
925
+            if (!isset($grouped[$group])) {
926 926
                 $grouped[$group] = array();
927 927
             }
928 928
             
@@ -940,8 +940,8 @@  discard block
 block discarded – undo
940 940
     public static function sourceExists(string $sourceID) : bool
941 941
     {
942 942
         $sources = self::getSources();
943
-        foreach($sources as $source) {
944
-            if($source->getID() == $sourceID) {
943
+        foreach ($sources as $source) {
944
+            if ($source->getID() == $sourceID) {
945 945
                 return true;
946 946
             }
947 947
         }
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
     public static function sourceAliasExists(string $sourceAlias) : bool
958 958
     {
959 959
         $sources = self::getSources();
960
-        foreach($sources as $source) {
961
-            if($source->getAlias() == $sourceAlias) {
960
+        foreach ($sources as $source) {
961
+            if ($source->getAlias() == $sourceAlias) {
962 962
                 return true;
963 963
             }
964 964
         }
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
     public static function getSourceByID(string $sourceID) : Localization_Source
977 977
     {
978 978
         $sources = self::getSources();
979
-        foreach($sources as $source) {
980
-            if($source->getID() == $sourceID) {
979
+        foreach ($sources as $source) {
980
+            if ($source->getID() == $sourceID) {
981 981
                 return $source;
982 982
             }
983 983
         }
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
     public static function getSourceByAlias(string $sourceAlias) : Localization_Source
1003 1003
     {
1004 1004
         $sources = self::getSources();
1005
-        foreach($sources as $source) {
1006
-            if($source->getAlias() == $sourceAlias) {
1005
+        foreach ($sources as $source) {
1006
+            if ($source->getAlias() == $sourceAlias) {
1007 1007
                 return $source;
1008 1008
             }
1009 1009
         }
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
      * @throws FileHelper_Exception
1048 1048
      * @throws Localization_Exception
1049 1049
      */
1050
-    public static function configure(string $storageFile, string $clientLibrariesFolder='') : void
1050
+    public static function configure(string $storageFile, string $clientLibrariesFolder = '') : void
1051 1051
     {
1052 1052
         self::$configured = true;
1053 1053
         
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 
1057 1057
         // only write the client libraries to disk if the folder
1058 1058
         // has been specified.
1059
-        if(!empty($clientLibrariesFolder)) 
1059
+        if (!empty($clientLibrariesFolder)) 
1060 1060
         {
1061 1061
             self::writeClientFiles();
1062 1062
         }
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
      * @throws Localization_Exception|FileHelper_Exception
1115 1115
      * @see Localization_ClientGenerator
1116 1116
      */
1117
-    public static function writeClientFiles(bool $force=false) : void
1117
+    public static function writeClientFiles(bool $force = false) : void
1118 1118
     {
1119 1119
         self::createGenerator()->writeFiles($force);
1120 1120
     }
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
      */
1148 1148
     protected static function requireConfiguration() : void
1149 1149
     {
1150
-        if(!self::$configured) 
1150
+        if (!self::$configured) 
1151 1151
         {
1152 1152
             throw new Localization_Exception(
1153 1153
                 'The localization configuration is incomplete.',
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
             );
1157 1157
         }
1158 1158
 
1159
-        if(empty(self::$storageFile))
1159
+        if (empty(self::$storageFile))
1160 1160
         {
1161 1161
             throw new Localization_Exception(
1162 1162
                 'No localization storage file set',
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
             );
1166 1166
         }
1167 1167
         
1168
-        if(empty(self::$sources)) 
1168
+        if (empty(self::$sources)) 
1169 1169
         {
1170 1170
             throw new Localization_Exception(
1171 1171
                 'No source folders have been defined.',
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
     {
1199 1199
         $ids = array();
1200 1200
         
1201
-        foreach(self::$sources as $source) {
1201
+        foreach (self::$sources as $source) {
1202 1202
             $ids[] = $source->getID();
1203 1203
         }
1204 1204
         
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
     {
1214 1214
         $aliases = array();
1215 1215
         
1216
-        foreach(self::$sources as $source) {
1216
+        foreach (self::$sources as $source) {
1217 1217
             $aliases[] = $source->getAlias();
1218 1218
         }
1219 1219
         
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
      */
1252 1252
     public static function getSupportedLocaleNames() : array
1253 1253
     {
1254
-        if(empty(self::$supportedLocales))
1254
+        if (empty(self::$supportedLocales))
1255 1255
         {
1256 1256
             self::$supportedLocales = FileHelper::createFileFinder(__DIR__.'/Localization/Locale')
1257 1257
                 ->getPHPClassNames();
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -246,8 +246,7 @@
 block discarded – undo
246 246
             {
247 247
                 return $locale;
248 248
             }
249
-        }
250
-        catch (Throwable $e)
249
+        } catch (Throwable $e)
251 250
         {
252 251
 
253 252
         }
Please login to merge, or discard this patch.
src/Localization/Locale.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
      */
33 33
     protected $country;
34 34
     
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     protected $countryCode;
39 39
     
40
-   /**
41
-    * @var string
42
-    */
40
+    /**
41
+     * @var string
42
+     */
43 43
     protected $languageCode;
44 44
 
45 45
     public function __construct()
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
         $this->languageCode = strtolower($tokens[0]);
54 54
     }
55 55
     
56
-   /**
57
-    * Retrieves the two-letter language code of the locale.
58
-    * 
59
-    * @return string Language code, e.g. "en", "de"
60
-    */
56
+    /**
57
+     * Retrieves the two-letter language code of the locale.
58
+     * 
59
+     * @return string Language code, e.g. "en", "de"
60
+     */
61 61
     public function getLanguageCode() : string
62 62
     {
63 63
         return $this->languageCode;
@@ -84,25 +84,25 @@  discard block
 block discarded – undo
84 84
         return $this->localeName;
85 85
     }
86 86
     
87
-   /**
88
-    * Retrieves the shortened version of the locale name,
89
-    * e.g. "en" or "de".
90
-    *
91
-    * @return string
92
-    * @deprecated
93
-    * @see Localization_Locale::getLanguageCode()
94
-    */
87
+    /**
88
+     * Retrieves the shortened version of the locale name,
89
+     * e.g. "en" or "de".
90
+     *
91
+     * @return string
92
+     * @deprecated
93
+     * @see Localization_Locale::getLanguageCode()
94
+     */
95 95
     public function getShortName() : string
96 96
     {
97 97
         return $this->getLanguageCode();
98 98
     }
99 99
     
100
-   /**
101
-    * Retrieves the two-letter country code of
102
-    * the locale.
103
-    * 
104
-    * @return string Lowercase code, e.g. "uk"
105
-    */
100
+    /**
101
+     * Retrieves the two-letter country code of
102
+     * the locale.
103
+     * 
104
+     * @return string Lowercase code, e.g. "uk"
105
+     */
106 106
     public function getCountryCode() : string
107 107
     {
108 108
         return $this->countryCode;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@
 block discarded – undo
137 137
      */
138 138
     public function getCountry() : Localization_Country
139 139
     {
140
-        if(!isset($this->country)) {
140
+        if (!isset($this->country)) {
141 141
             $this->country = Localization::createCountry($this->countryCode);
142 142
         }
143 143
         
Please login to merge, or discard this patch.