Passed
Push — master ( 8b5ce5...b7fcc1 )
by Sebastian
12:08
created
src/Localization/Countries/CountryCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
 
76 76
     public function choose() : CannedCountries
77 77
     {
78
-        if(!isset($this->canned)) {
78
+        if (!isset($this->canned)) {
79 79
             $this->canned = new CannedCountries();
80 80
         }
81 81
 
Please login to merge, or discard this patch.
src/Localization/Countries/CountryCurrency.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         return $this->currency->isNamePreferred();
68 68
     }
69 69
 
70
-    public function getStructuralTemplate(?CountryInterface $country=null): string
70
+    public function getStructuralTemplate(?CountryInterface $country = null): string
71 71
     {
72 72
         return $this->currency->getStructuralTemplate($this->country);
73 73
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             return true;
85 85
         }
86 86
 
87
-        return preg_match($this->getRegex(), (string)$number) !== false;
87
+        return preg_match($this->getRegex(), (string) $number) !== false;
88 88
     }
89 89
 
90 90
     protected $regex = '/\A([0-9%1$s]+)\z|([0-9%1$s]+),-\z|([0-9%1$s]+)[%2$s]([0-9]+)\z/s';
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             $thousands = implode('', $parts);
187 187
         }
188 188
 
189
-        return new CurrencyNumberInfo((int)$thousands, (int)$decimals);
189
+        return new CurrencyNumberInfo((int) $thousands, (int) $decimals);
190 190
     }
191 191
 
192 192
     /**
@@ -195,17 +195,17 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public function normalizeNumber($number) : string
197 197
     {
198
-        if($number === '' || $number === null) {
198
+        if ($number === '' || $number === null) {
199 199
             return '';
200 200
         }
201 201
 
202
-        $normalized = str_replace(' ', '', (string)$number);
202
+        $normalized = str_replace(' ', '', (string) $number);
203 203
         $dSep = $this->getDecimalsSeparator();
204 204
         $tSep = $this->getThousandsSeparator();
205 205
 
206 206
         // Handle the case where both classical separators are used,
207 207
         // independently of the country's specific separators.
208
-        if(strpos($normalized, '.') !== false && strpos($normalized, ',') !== false) {
208
+        if (strpos($normalized, '.') !== false && strpos($normalized, ',') !== false) {
209 209
             $normalized = str_replace(array('.', ','), '.', $normalized);
210 210
             $parts = explode('.', $normalized);
211 211
             $decimals = array_pop($parts);
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     public function formatNumber($number, int $decimalPositions = 2) : string
246 246
     {
247 247
         return number_format(
248
-            (float)$number,
248
+            (float) $number,
249 249
             $decimalPositions,
250 250
             $this->getDecimalsSeparator(),
251 251
             $this->getThousandsSeparator()
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         return $this->country->getNumberDecimalsSeparator();
263 263
     }
264 264
 
265
-    public function makeReadable($number, int $decimalPositions = 2, bool $addSymbol=true) : string
265
+    public function makeReadable($number, int $decimalPositions = 2, bool $addSymbol = true) : string
266 266
     {
267 267
         if ($number === null || $number === '') {
268 268
             return '';
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
             $decimalPositions
276 276
         );
277 277
 
278
-        if(!$addSymbol) {
278
+        if (!$addSymbol) {
279 279
             return $number;
280 280
         }
281 281
 
282 282
         $sign = '';
283
-        if($parsed->isNegative()) {
283
+        if ($parsed->isNegative()) {
284 284
             $sign = '-';
285 285
         }
286 286
 
@@ -299,6 +299,6 @@  discard block
 block discarded – undo
299 299
 
300 300
     public function __toString()
301 301
     {
302
-        return (string)$this->currency;
302
+        return (string) $this->currency;
303 303
     }
304 304
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -179,8 +179,7 @@
 block discarded – undo
179 179
             if ($decimals === '-') {
180 180
                 $decimals = 0;
181 181
             }
182
-        }
183
-        else
182
+        } else
184 183
         {
185 184
             $decimals = 0;
186 185
             $thousands = implode('', $parts);
Please login to merge, or discard this patch.
src/Localization/Currencies/CurrencyCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 
65 65
     public function choose() : CannedCurrencies
66 66
     {
67
-        if(!isset($this->canned)) {
67
+        if (!isset($this->canned)) {
68 68
             $this->canned = new CannedCurrencies();
69 69
         }
70 70
 
Please login to merge, or discard this patch.
src/Localization/Currencies/CurrencyInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
      *      Add the country to guarantee the matching formatting, otherwise the default formatting is returned.
53 53
      * @return string
54 54
      */
55
-    public function getStructuralTemplate(?CountryInterface $country=null) : string;
55
+    public function getStructuralTemplate(?CountryInterface $country = null) : string;
56 56
 
57 57
     /**
58 58
      * Whether the symbol is typically shown at the beginning of the amount.
Please login to merge, or discard this patch.
src/Localization/Currencies/BaseCurrency.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
         $countries = array();
51 51
         $iso = $this->getISO();
52 52
 
53
-        foreach(Localization::createCountries()->getAll() as $country) {
54
-            if($country->getCurrencyISO() === $iso) {
53
+        foreach (Localization::createCountries()->getAll() as $country) {
54
+            if ($country->getCurrencyISO() === $iso) {
55 55
                 $countries[] = $country;
56 56
             }
57 57
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
     public function getPreferredSymbol(): string
86 86
     {
87
-        if($this->isNamePreferred()) {
87
+        if ($this->isNamePreferred()) {
88 88
             return $this->getISO();
89 89
         }
90 90
 
Please login to merge, or discard this patch.
src/Localization.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     */
124 124
     public static function init() : void
125 125
     {
126
-        if(self::$initDone) {
126
+        if (self::$initDone) {
127 127
             return;
128 128
         }
129 129
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     */
168 168
     public static function getLocalesByNS(string $namespace)
169 169
     {
170
-        if(isset(self::$locales[$namespace])) {
170
+        if (isset(self::$locales[$namespace])) {
171 171
             return array_values(self::$locales[$namespace]);
172 172
         }
173 173
         
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
     */
213 213
     public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale
214 214
     {
215
-        if(!isset(self::$locales[$namespace])) {
215
+        if (!isset(self::$locales[$namespace])) {
216 216
             self::$locales[$namespace] = array();
217 217
         }
218 218
         
219
-        if(!isset(self::$locales[$namespace][$localeName])) 
219
+        if (!isset(self::$locales[$namespace][$localeName])) 
220 220
         {
221 221
             self::$locales[$namespace][$localeName] = self::createLocale($localeName);
222 222
             
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public static function createCountries() : CountryCollection
277 277
     {
278
-        if(!isset(self::$countries)) {
278
+        if (!isset(self::$countries)) {
279 279
             self::$countries = CountryCollection::getInstance();
280 280
         }
281 281
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
      */
293 293
     public static function createCurrencies() : CurrencyCollection
294 294
     {
295
-        if(!isset(self::$currencies)) {
295
+        if (!isset(self::$currencies)) {
296 296
             self::$currencies = CurrencyCollection::getInstance();
297 297
         }
298 298
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
     {
406 406
         self::requireNamespace($namespace);
407 407
         
408
-        if(isset(self::$selected[$namespace])) {
408
+        if (isset(self::$selected[$namespace])) {
409 409
             return self::$selected[$namespace];
410 410
         }
411 411
         
@@ -444,9 +444,9 @@  discard block
 block discarded – undo
444 444
         $locale = self::addLocaleByNS($localeName, $namespace);
445 445
         $previous = null;
446 446
         
447
-        if(isset(self::$selected[$namespace])) 
447
+        if (isset(self::$selected[$namespace])) 
448 448
         {
449
-            if(self::$selected[$namespace]->getName() === $localeName) {
449
+            if (self::$selected[$namespace]->getName() === $localeName) {
450 450
                 return $locale;
451 451
             }
452 452
             
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
         $class = Localization_Event::class.'_'.$name;
483 483
         $event = new $class($argsList);
484 484
         
485
-        if(!isset(self::$listeners[$name])) {
485
+        if (!isset(self::$listeners[$name])) {
486 486
             return $event;
487 487
         }
488 488
         
489
-        foreach(self::$listeners[$name] as $listener) 
489
+        foreach (self::$listeners[$name] as $listener) 
490 490
         {
491 491
             $callArgs = $listener['args'];
492 492
             array_unshift($callArgs, $event);
@@ -508,15 +508,15 @@  discard block
 block discarded – undo
508 508
      * @throws Localization_Exception
509 509
      * @see Localization::ERROR_UNKNOWN_EVENT_NAME
510 510
      */
511
-    public static function addEventListener(string $eventName, $callback, array $args=array()) : int
511
+    public static function addEventListener(string $eventName, $callback, array $args = array()) : int
512 512
     {
513
-        if(!isset(self::$listeners[$eventName])) {
513
+        if (!isset(self::$listeners[$eventName])) {
514 514
             self::$listeners[$eventName] = array();
515 515
         }
516 516
         
517 517
         $className = Localization_Event::class.'_'.$eventName;
518 518
         
519
-        if(!class_exists($className)) 
519
+        if (!class_exists($className)) 
520 520
         {
521 521
             throw new Localization_Exception(
522 522
                 sprintf('Unknown localization event [%s].', $eventName),
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
      * @throws Localization_Exception
551 551
      * @see Localization_Event_LocaleChanged
552 552
      */
553
-    public static function onLocaleChanged($callback, array $args=array()) : int
553
+    public static function onLocaleChanged($callback, array $args = array()) : int
554 554
     {
555 555
         return self::addEventListener(self::EVENT_LOCALE_CHANGED, $callback, $args);
556 556
     }
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
     {
678 678
         self::requireNamespace($namespace);
679 679
         
680
-        if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) {
680
+        if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) {
681 681
             return self::$locales[$namespace][$localeName];
682 682
         }
683 683
         
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
      * @param Localization_Locale|null $locale
757 757
      * @return Localization_Translator
758 758
      */
759
-    public static function getTranslator(?Localization_Locale $locale=null) : Localization_Translator
759
+    public static function getTranslator(?Localization_Locale $locale = null) : Localization_Translator
760 760
     {
761
-        if($locale !== null)
761
+        if ($locale !== null)
762 762
         {
763 763
             $obj = new Localization_Translator();
764 764
             $obj->addSources(self::getSources());
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
             return $obj;
767 767
         }
768 768
             
769
-        if(!isset(self::$translator)) 
769
+        if (!isset(self::$translator)) 
770 770
         {
771 771
             $obj = new Localization_Translator();
772 772
             $obj->addSources(self::getSources());
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     {
792 792
         self::requireNamespace($namespace);
793 793
         
794
-        if(isset(self::$locales[$namespace])) {
794
+        if (isset(self::$locales[$namespace])) {
795 795
             return count(self::$locales[$namespace]);
796 796
         }
797 797
         
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
      */
805 805
     protected static function requireNamespace(string $namespace) : void
806 806
     {
807
-        if(isset(self::$locales[$namespace])) {
807
+        if (isset(self::$locales[$namespace])) {
808 808
             return;
809 809
         }
810 810
         
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
     * @param string $label
828 828
     * @return HTML_QuickForm2_Element_Select
829 829
     */
830
-    public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
830
+    public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
831 831
     {
832 832
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label);
833 833
     }
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
     * @param string $label
842 842
     * @return HTML_QuickForm2_Element_Select
843 843
     */
844
-    public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
844
+    public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
845 845
     {
846 846
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label);
847 847
     }
@@ -858,9 +858,9 @@  discard block
 block discarded – undo
858 858
      * @return HTML_QuickForm2_Element_Select
859 859
      * @throws Localization_Exception
860 860
      */
861
-    public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
861
+    public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
862 862
     {
863
-        if(empty($label)) {
863
+        if (empty($label)) {
864 864
             $label = t('Language');
865 865
         }
866 866
 
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 
870 870
         $locales = self::getLocalesByNS($namespace);
871 871
         
872
-        foreach($locales as $locale) {
872
+        foreach ($locales as $locale) {
873 873
             $select->addOption($locale->getLabel(), $locale->getName());
874 874
         }
875 875
 
@@ -903,14 +903,14 @@  discard block
 block discarded – undo
903 903
     
904 904
     public static function addExcludeFolder(string $folderName) : void
905 905
     { 
906
-        if(!in_array($folderName, self::$excludeFolders)) {
906
+        if (!in_array($folderName, self::$excludeFolders)) {
907 907
             self::$excludeFolders[] = $folderName;
908 908
         }
909 909
     }
910 910
     
911 911
     public static function addExcludeFile(string $fileName) : void
912 912
     {
913
-        if(!in_array($fileName, self::$excludeFiles)) {
913
+        if (!in_array($fileName, self::$excludeFiles)) {
914 914
             self::$excludeFiles[] = $fileName;
915 915
         }
916 916
     }
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
         
938 938
         $grouped = array();
939 939
         
940
-        foreach($sources as $source) 
940
+        foreach ($sources as $source) 
941 941
         {
942 942
             $group = $source->getGroup();
943 943
             
944
-            if(!isset($grouped[$group])) {
944
+            if (!isset($grouped[$group])) {
945 945
                 $grouped[$group] = array();
946 946
             }
947 947
             
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
     public static function sourceExists(string $sourceID) : bool
960 960
     {
961 961
         $sources = self::getSources();
962
-        foreach($sources as $source) {
963
-            if($source->getID() == $sourceID) {
962
+        foreach ($sources as $source) {
963
+            if ($source->getID() == $sourceID) {
964 964
                 return true;
965 965
             }
966 966
         }
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
     public static function sourceAliasExists(string $sourceAlias) : bool
977 977
     {
978 978
         $sources = self::getSources();
979
-        foreach($sources as $source) {
980
-            if($source->getAlias() == $sourceAlias) {
979
+        foreach ($sources as $source) {
980
+            if ($source->getAlias() == $sourceAlias) {
981 981
                 return true;
982 982
             }
983 983
         }
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
     public static function getSourceByID(string $sourceID) : Localization_Source
996 996
     {
997 997
         $sources = self::getSources();
998
-        foreach($sources as $source) {
999
-            if($source->getID() == $sourceID) {
998
+        foreach ($sources as $source) {
999
+            if ($source->getID() == $sourceID) {
1000 1000
                 return $source;
1001 1001
             }
1002 1002
         }
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
     public static function getSourceByAlias(string $sourceAlias) : Localization_Source
1022 1022
     {
1023 1023
         $sources = self::getSources();
1024
-        foreach($sources as $source) {
1025
-            if($source->getAlias() == $sourceAlias) {
1024
+        foreach ($sources as $source) {
1025
+            if ($source->getAlias() == $sourceAlias) {
1026 1026
                 return $source;
1027 1027
             }
1028 1028
         }
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
      * @throws FileHelper_Exception
1067 1067
      * @throws Localization_Exception
1068 1068
      */
1069
-    public static function configure(string $storageFile, string $clientLibrariesFolder='') : void
1069
+    public static function configure(string $storageFile, string $clientLibrariesFolder = '') : void
1070 1070
     {
1071 1071
         self::$configured = true;
1072 1072
         
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 
1076 1076
         // only write the client libraries to disk if the folder
1077 1077
         // has been specified.
1078
-        if(!empty($clientLibrariesFolder)) 
1078
+        if (!empty($clientLibrariesFolder)) 
1079 1079
         {
1080 1080
             self::writeClientFiles();
1081 1081
         }
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
      * @throws Localization_Exception|FileHelper_Exception
1134 1134
      * @see Localization_ClientGenerator
1135 1135
      */
1136
-    public static function writeClientFiles(bool $force=false) : void
1136
+    public static function writeClientFiles(bool $force = false) : void
1137 1137
     {
1138 1138
         self::createGenerator()->writeFiles($force);
1139 1139
     }
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
      */
1167 1167
     protected static function requireConfiguration() : void
1168 1168
     {
1169
-        if(!self::$configured) 
1169
+        if (!self::$configured) 
1170 1170
         {
1171 1171
             throw new Localization_Exception(
1172 1172
                 'The localization configuration is incomplete.',
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
             );
1176 1176
         }
1177 1177
 
1178
-        if(empty(self::$storageFile))
1178
+        if (empty(self::$storageFile))
1179 1179
         {
1180 1180
             throw new Localization_Exception(
1181 1181
                 'No localization storage file set',
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
             );
1185 1185
         }
1186 1186
         
1187
-        if(empty(self::$sources)) 
1187
+        if (empty(self::$sources)) 
1188 1188
         {
1189 1189
             throw new Localization_Exception(
1190 1190
                 'No source folders have been defined.',
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
     {
1218 1218
         $ids = array();
1219 1219
         
1220
-        foreach(self::$sources as $source) {
1220
+        foreach (self::$sources as $source) {
1221 1221
             $ids[] = $source->getID();
1222 1222
         }
1223 1223
         
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
     {
1233 1233
         $aliases = array();
1234 1234
         
1235
-        foreach(self::$sources as $source) {
1235
+        foreach (self::$sources as $source) {
1236 1236
             $aliases[] = $source->getAlias();
1237 1237
         }
1238 1238
         
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
      */
1271 1271
     public static function getSupportedLocaleNames() : array
1272 1272
     {
1273
-        if(empty(self::$supportedLocales))
1273
+        if (empty(self::$supportedLocales))
1274 1274
         {
1275 1275
             self::$supportedLocales = FileHelper::createFileFinder(__DIR__.'/Localization/Locale')
1276 1276
                 ->getPHPClassNames();
Please login to merge, or discard this patch.