Passed
Push — master ( f58fec...1e5d9f )
by Sebastian
06:14
created
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.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.
src/Localization/Scanner/StringHash.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class Localization_Scanner_StringHash
17 17
 {
18
-   /**
19
-    * @var Localization_Scanner_StringsCollection
20
-    */
18
+    /**
19
+     * @var Localization_Scanner_StringsCollection
20
+     */
21 21
     protected $collection;
22 22
     
23
-   /**
24
-    * @var string
25
-    */
23
+    /**
24
+     * @var string
25
+     */
26 26
     protected $hash;
27 27
     
28
-   /**
29
-    * @var Localization_Scanner_StringInfo[]
30
-    */
28
+    /**
29
+     * @var Localization_Scanner_StringInfo[]
30
+     */
31 31
     protected $strings = array();
32 32
 
33 33
     /**
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
         return $entries;
61 61
     }
62 62
     
63
-   /**
64
-    * Retrieves all individual string locations where this text was found.
65
-    * @return Localization_Scanner_StringInfo[]
66
-    */
63
+    /**
64
+     * Retrieves all individual string locations where this text was found.
65
+     * @return Localization_Scanner_StringInfo[]
66
+     */
67 67
     public function getStrings() : array
68 68
     {
69 69
         return $this->strings;
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
         return count($this->strings);
124 124
     }
125 125
     
126
-   /**
127
-    * Retrieves the translated text, if any.
128
-    * @return string
129
-    */
126
+    /**
127
+     * Retrieves the translated text, if any.
128
+     * @return string
129
+     */
130 130
     public function getTranslatedText() : string
131 131
     {
132 132
         $translator = Localization::getTranslator();
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
         return '';
140 140
     }
141 141
     
142
-   /**
143
-    * Retrieves a list of all file names, with relative paths.
144
-    * @return string[]
145
-    */
142
+    /**
143
+     * Retrieves a list of all file names, with relative paths.
144
+     * @return string[]
145
+     */
146 146
     public function getFiles() : array
147 147
     {
148 148
         $files = array();
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
         return $files;
165 165
     }
166 166
     
167
-   /**
168
-    * Retrieves a list of all file names this string is used in.
169
-    * @return string[]
170
-    */
167
+    /**
168
+     * Retrieves a list of all file names this string is used in.
169
+     * @return string[]
170
+     */
171 171
     public function getFileNames() : array
172 172
     {
173 173
         $files = $this->getFiles();
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
         return array_unique($result);
183 183
     }
184 184
     
185
-   /**
186
-    * Retrieves a text comprised of all strings that are relevant
187
-    * for a full text search, imploded together. Used in the search
188
-    * function to find matching strings.
189
-    * 
190
-    * @return string
191
-    */
185
+    /**
186
+     * Retrieves a text comprised of all strings that are relevant
187
+     * for a full text search, imploded together. Used in the search
188
+     * function to find matching strings.
189
+     * 
190
+     * @return string
191
+     */
192 192
     public function getSearchString() : string
193 193
     {
194 194
         $parts = array($this->getTranslatedText(), $this->getTextAsString());
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $entries = array();
55 55
        
56
-        foreach($this->strings as $string) {
56
+        foreach ($this->strings as $string) {
57 57
             $entries[] = $string->toArray();
58 58
         }
59 59
         
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $amount = 0;
75 75
         
76
-        foreach($this->strings as $string) {
77
-            if($string->isFile()) {
76
+        foreach ($this->strings as $string) {
77
+            if ($string->isFile()) {
78 78
                 $amount++;
79 79
             }
80 80
         }
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
     
90 90
     public function hasLanguageType(string $type) : bool
91 91
     {
92
-        foreach($this->strings as $string) {
93
-            if($string->getLanguageType() == $type) {
92
+        foreach ($this->strings as $string) {
93
+            if ($string->getLanguageType() == $type) {
94 94
                 return true;
95 95
             }
96 96
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     
101 101
     public function getText() : ?Text
102 102
     {
103
-        if(isset($this->strings[0])) {
103
+        if (isset($this->strings[0])) {
104 104
             return $this->strings[0]->getText();
105 105
         }
106 106
         
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $translator = Localization::getTranslator();
133 133
         $text = $translator->getHashTranslation($this->getHash());
134 134
         
135
-        if($text !== null) {
135
+        if ($text !== null) {
136 136
             return $text;
137 137
         }
138 138
         
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
     {
148 148
         $files = array();
149 149
         
150
-        foreach($this->strings as $string) 
150
+        foreach ($this->strings as $string) 
151 151
         {
152
-            if(!$string->isFile()) {
152
+            if (!$string->isFile()) {
153 153
                 continue;
154 154
             }
155 155
             
156 156
             $file = $string->getSourceFile();
157
-            if(!in_array($file, $files)) {
157
+            if (!in_array($file, $files)) {
158 158
                 $files[] = $file;
159 159
             }
160 160
         }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         $files = $this->getFiles();
174 174
         $result = array();
175 175
         
176
-        foreach($files as $path) {
176
+        foreach ($files as $path) {
177 177
             $result[] = basename($path);
178 178
         }
179 179
         
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     {
203 203
         $text = $this->getText();
204 204
 
205
-        if($text !== null)
205
+        if ($text !== null)
206 206
         {
207 207
             return $text->getText();
208 208
         }
Please login to merge, or discard this patch.
src/Localization/Editor/Template/PageScaffold.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 <?php $this->renderAppLocales(); ?>
73 73
                 <?php
74 74
                 $backURL = $this->editor->getBackURL();
75
-                if(!empty($backURL))
75
+                if (!empty($backURL))
76 76
                 {
77 77
                     ?>
78 78
                     <a href="<?php echo $backURL ?>" class="btn btn-light btn-sm">
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             <?php
110 110
             $warnings = $this->editor->getScannerWarnings();
111 111
 
112
-            foreach($warnings as $warning)
112
+            foreach ($warnings as $warning)
113 113
             {
114 114
                 ?>
115 115
                 <dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt>
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $strings = $this->editor->getFilteredStrings();
128 128
 
129
-        if(empty($strings))
129
+        if (empty($strings))
130 130
         {
131 131
             ?>
132 132
             <div class="alert alert-info">
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             <div class="form-hiddens">
149 149
                 <?php
150 150
                 $params = $this-> editor->getRequestParams();
151
-                foreach($params as $name => $value) {
151
+                foreach ($params as $name => $value) {
152 152
                     ?>
153 153
                     <input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>">
154 154
                     <?php
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                 </thead>
167 167
                 <tbody>
168 168
                 <?php
169
-                foreach($keep as $string)
169
+                foreach ($keep as $string)
170 170
                 {
171 171
                     $this->renderTextEditorEntry($string);
172 172
                 }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                 </tbody>
175 175
             </table>
176 176
             <?php
177
-            if($pager->hasPages())
177
+            if ($pager->hasPages())
178 178
             {
179 179
                 $prevUrl = $this->editor->getPaginationURL($pager->getPreviousPage());
180 180
                 $nextUrl = $this->editor->getPaginationURL($pager->getNextPage());
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
                         </li>
190 190
                         <?php
191 191
                         $numbers = $pager->getPageNumbers();
192
-                        foreach($numbers as $number)
192
+                        foreach ($numbers as $number)
193 193
                         {
194 194
                             $url = $this->editor->getPaginationURL($number);
195 195
 
196 196
                             ?>
197
-                            <li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>">
197
+                            <li class="page-item <?php if ($pager->isCurrentPage($number)) { echo 'active'; } ?>">
198 198
                                 <a class="page-link" href="<?php echo $url ?>">
199 199
                                     <?php echo $number ?>
200 200
                                 </a>
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         $hash = $string->getHash();
230 230
         $text = $string->getText();
231 231
 
232
-        if($text===null)
232
+        if ($text === null)
233 233
         {
234 234
             throw new EditorException(
235 235
                 'String hash has no text',
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
         }
240 240
 
241 241
         $previewText = $string->getTranslatedText();
242
-        if(empty($previewText)) {
242
+        if (empty($previewText)) {
243 243
             $previewText = $text->getText();
244 244
         }
245 245
 
246
-        $shortText =  $this->renderText($previewText, 50);
246
+        $shortText = $this->renderText($previewText, 50);
247 247
 
248 248
         $files = $string->getFiles();
249 249
         $labelID = JSHelper::nextElementID();
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
                 </p>
265 265
                 <?php
266 266
                 $explanation = $text->getExplanation();
267
-                if(!empty($explanation))
267
+                if (!empty($explanation))
268 268
                 {
269 269
                     ?>
270 270
                     <p>
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                         <?php
288 288
                         $totalFiles = count($files);
289 289
 
290
-                        if($totalFiles == 1)
290
+                        if ($totalFiles == 1)
291 291
                         {
292 292
                             pt('Found in a single file:');
293 293
                         }
@@ -302,16 +302,16 @@  discard block
 block discarded – undo
302 302
                             <?php
303 303
                             $locations = $string->getStrings();
304 304
 
305
-                            foreach($locations as $location)
305
+                            foreach ($locations as $location)
306 306
                             {
307 307
                                 $file = $location->getSourceFile();
308 308
                                 $line = $location->getLine();
309 309
 
310 310
                                 $ext = FileHelper::getExtension($file);
311 311
 
312
-                                if($ext == 'php') {
312
+                                if ($ext == 'php') {
313 313
                                     $icon = 'fab fa-php';
314
-                                } else if($ext == 'js') {
314
+                                } else if ($ext == 'js') {
315 315
                                     $icon = 'fab fa-js-square';
316 316
                                 } else {
317 317
                                     $icon = 'fas fa-file-code';
@@ -333,13 +333,13 @@  discard block
 block discarded – undo
333 333
         <?php
334 334
     }
335 335
 
336
-    protected function renderText(string $text, int $cutAt=0) : string
336
+    protected function renderText(string $text, int $cutAt = 0) : string
337 337
     {
338
-        if(empty($text)) {
338
+        if (empty($text)) {
339 339
             return '';
340 340
         }
341 341
 
342
-        if($cutAt > 0) {
342
+        if ($cutAt > 0) {
343 343
             $text = ConvertHelper::text_cut($text, $cutAt);
344 344
         }
345 345
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
         $vars = $this->editor->detectVariables($text);
349 349
 
350
-        foreach($vars as $var) {
350
+        foreach ($vars as $var) {
351 351
             $text = str_replace($var, '<span class="placeholder">'.$var.'</span>', $text);
352 352
         }
353 353
 
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
             <?php
533 533
             pt(
534 534
                 'You are translating to %1$s',
535
-                '<span class="badge badge-info">' . $activeLocale->getLabel() . '</span>'
535
+                '<span class="badge badge-info">'.$activeLocale->getLabel().'</span>'
536 536
             );
537 537
             ?><br>
538 538
 
@@ -572,10 +572,10 @@  discard block
 block discarded – undo
572 572
 
573 573
         // add a counter of the additional files if the total
574 574
         // is higher than the maximum to show
575
-        if($total > $max)
575
+        if ($total > $max)
576 576
         {
577 577
             $length = $max;
578
-            if($length > $keepTotal) {
578
+            if ($length > $keepTotal) {
579 579
                 $length = $keepTotal;
580 580
             }
581 581
 
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 
589 589
     protected function renderStatus(Localization_Scanner_StringHash $hash) : string
590 590
     {
591
-        if($hash->isTranslated()) {
591
+        if ($hash->isTranslated()) {
592 592
             return '<i class="fa fa-check text-success"></i>';
593 593
         }
594 594
 
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
     {
600 600
         $types = array();
601 601
 
602
-        if($hash->hasLanguageType('PHP')) {
602
+        if ($hash->hasLanguageType('PHP')) {
603 603
             $types[] = t('Server');
604 604
         }
605 605
 
606
-        if($hash->hasLanguageType('Javascript')) {
606
+        if ($hash->hasLanguageType('Javascript')) {
607 607
             $types[] = t('Client');
608 608
         }
609 609
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -290,8 +290,7 @@  discard block
 block discarded – undo
290 290
                         if($totalFiles == 1)
291 291
                         {
292 292
                             pt('Found in a single file:');
293
-                        }
294
-                        else
293
+                        } else
295 294
                         {
296 295
                             pt('Found in %1$s files:', $totalFiles);
297 296
                         }
@@ -463,8 +462,7 @@  discard block
 block discarded – undo
463 462
                     ?>
464 463
                     <b><?php echo $source->getLabel() ?></b>
465 464
                     <?php
466
-                }
467
-                else
465
+                } else
468 466
                 {
469 467
                     echo $source->getLabel();
470 468
                 }
@@ -554,8 +552,7 @@  discard block
 block discarded – undo
554 552
                 </a>
555 553
             </p>
556 554
             <?php
557
-        }
558
-        else
555
+        } else
559 556
         {
560 557
             echo $this->editor->getFilters()->renderForm();
561 558
 
Please login to merge, or discard this patch.
src/Localization/Source/Scanner.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
         $texts = $language->getTexts();
61 61
 
62
-        foreach($texts as $text)
62
+        foreach ($texts as $text)
63 63
         {
64 64
             $this->collection->addFromFile(
65 65
                 $this->source->getID(),
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
         $warnings = $language->getWarnings();
73 73
 
74
-        foreach($warnings as $warning)
74
+        foreach ($warnings as $warning)
75 75
         {
76 76
             $this->collection->addWarning($warning);
77 77
         }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 
94 94
         $hashes = $this->getHashes();
95 95
 
96
-        foreach($hashes as $hash)
96
+        foreach ($hashes as $hash)
97 97
         {
98 98
             $text = $translator->getHashTranslation($hash->getHash());
99 99
 
100
-            if(empty($text))
100
+            if (empty($text))
101 101
             {
102 102
                 $amount++;
103 103
             }
Please login to merge, or discard this patch.
src/Localization/Source.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,27 +27,27 @@
 block discarded – undo
27 27
  */
28 28
 abstract class Localization_Source
29 29
 {
30
-   /**
31
-    * Human-readable label for the source.
32
-    * @var string
33
-    */
30
+    /**
31
+     * Human-readable label for the source.
32
+     * @var string
33
+     */
34 34
     protected $label;
35 35
     
36
-   /**
37
-    * Human-readable group name to categorize the source.
38
-    * @var string
39
-    */
36
+    /**
37
+     * Human-readable group name to categorize the source.
38
+     * @var string
39
+     */
40 40
     protected $group;
41 41
     
42
-   /**
43
-    * The folder in which the localization files are stored
44
-    * @var string
45
-    */
42
+    /**
43
+     * The folder in which the localization files are stored
44
+     * @var string
45
+     */
46 46
     protected $storageFolder;
47 47
     
48
-   /**
49
-    * @var string
50
-    */
48
+    /**
49
+     * @var string
50
+     */
51 51
     protected $alias;
52 52
 
53 53
     public function __construct(string $alias, string $label, string $group, string $storageFolder)
Please login to merge, or discard this patch.