Passed
Push — master ( 4a5f5f...d4ccbb )
by Sebastian
03:14
created
src/Localization.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
     const EVENT_LOCALE_CHANGED = 'LocaleChanged';
49 49
 
50 50
     /**
51
-    * Collection of all locales by namespace (application, content, custom...). 
52
-    *
53
-    * @var array<string,array<string,Localization_Locale>>
54
-    * @see Localization::addLocale()
55
-    */
51
+     * Collection of all locales by namespace (application, content, custom...). 
52
+     *
53
+     * @var array<string,array<string,Localization_Locale>>
54
+     * @see Localization::addLocale()
55
+     */
56 56
     protected static $locales = array();
57 57
 
58 58
     /**
@@ -61,57 +61,57 @@  discard block
 block discarded – undo
61 61
      */
62 62
     private static $initDone = false;
63 63
 
64
-   /**
65
-    * Path to the file in which the scanner results are stored.
66
-    * @var string
67
-    * @see Localization::configure()
68
-    */
64
+    /**
65
+     * Path to the file in which the scanner results are stored.
66
+     * @var string
67
+     * @see Localization::configure()
68
+     */
69 69
     protected static $storageFile = '';
70 70
     
71
-   /**
72
-    * Path to the folder into which the client libraries are written.
73
-    * @var string
74
-    * @see Localization::setClientLibrariesFolder()
75
-    */
71
+    /**
72
+     * Path to the folder into which the client libraries are written.
73
+     * @var string
74
+     * @see Localization::setClientLibrariesFolder()
75
+     */
76 76
     protected static $clientFolder = '';
77 77
     
78
-   /**
79
-    * If this key changes, client libraries are refreshed.
80
-    * @var string
81
-    * @see Localization::setClientLibrariesCacheKey()
82
-    */
78
+    /**
79
+     * If this key changes, client libraries are refreshed.
80
+     * @var string
81
+     * @see Localization::setClientLibrariesCacheKey()
82
+     */
83 83
     protected static $clientCacheKey = '';
84 84
     
85
-   /**
86
-    * Whether the configuration has been made.
87
-    * @var bool
88
-    * @see Localization::configure()
89
-    */
85
+    /**
86
+     * Whether the configuration has been made.
87
+     * @var bool
88
+     * @see Localization::configure()
89
+     */
90 90
     protected static $configured = false;
91 91
     
92
-   /**
93
-    * Stores event listener instances.
94
-    * @var array
95
-    */
92
+    /**
93
+     * Stores event listener instances.
94
+     * @var array
95
+     */
96 96
     protected static $listeners = array();
97 97
     
98
-   /**
99
-    * @var integer
100
-    * @see Localization::addEventListener()
101
-    */
98
+    /**
99
+     * @var integer
100
+     * @see Localization::addEventListener()
101
+     */
102 102
     protected static $listenersCounter = 0;
103 103
     
104
-   /**
105
-    * @var Localization_Translator|NULL
106
-    */
104
+    /**
105
+     * @var Localization_Translator|NULL
106
+     */
107 107
     protected static $translator;
108 108
     
109
-   /**
110
-    * Initializes the localization layer. This is done
111
-    * automatically, and only once per request.
112
-    * 
113
-    * (Called at the end of this file)
114
-    */
109
+    /**
110
+     * Initializes the localization layer. This is done
111
+     * automatically, and only once per request.
112
+     * 
113
+     * (Called at the end of this file)
114
+     */
115 115
     public static function init() : void
116 116
     {
117 117
         if(self::$initDone) {
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
         return self::getLocalesByNS(self::NAMESPACE_APPLICATION);
151 151
     }
152 152
     
153
-   /**
154
-    * Retrieves all locales in the specified namespace.
155
-    * 
156
-    * @param string $namespace
157
-    * @return Localization_Locale[]
158
-    */
153
+    /**
154
+     * Retrieves all locales in the specified namespace.
155
+     * 
156
+     * @param string $namespace
157
+     * @return Localization_Locale[]
158
+     */
159 159
     public static function getLocalesByNS(string $namespace)
160 160
     {
161 161
         if(isset(self::$locales[$namespace])) {
@@ -172,35 +172,35 @@  discard block
 block discarded – undo
172 172
         );
173 173
     }
174 174
     
175
-   /**
176
-    * Adds an application locale to use in the application.
177
-    * 
178
-    * @param string $localeName
179
-    * @return Localization_Locale
180
-    */
175
+    /**
176
+     * Adds an application locale to use in the application.
177
+     * 
178
+     * @param string $localeName
179
+     * @return Localization_Locale
180
+     */
181 181
     public static function addAppLocale(string $localeName) : Localization_Locale
182 182
     {
183 183
         return self::addLocaleByNS($localeName, self::NAMESPACE_APPLICATION);
184 184
     }
185 185
     
186
-   /**
187
-    * Adds a content locale to use for content in the application.
188
-    * 
189
-    * @param string $localeName
190
-    * @return Localization_Locale
191
-    */
186
+    /**
187
+     * Adds a content locale to use for content in the application.
188
+     * 
189
+     * @param string $localeName
190
+     * @return Localization_Locale
191
+     */
192 192
     public static function addContentLocale(string $localeName) : Localization_Locale
193 193
     {
194 194
         return self::addLocaleByNS($localeName, self::NAMESPACE_CONTENT);
195 195
     }
196 196
     
197
-   /**
198
-    * Adds a locale to the specified namespace.
199
-    * 
200
-    * @param string $localeName
201
-    * @param string $namespace
202
-    * @return Localization_Locale
203
-    */
197
+    /**
198
+     * Adds a locale to the specified namespace.
199
+     * 
200
+     * @param string $localeName
201
+     * @param string $namespace
202
+     * @return Localization_Locale
203
+     */
204 204
     public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale
205 205
     {
206 206
         if(!isset(self::$locales[$namespace])) {
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
         return new $className();
243 243
     }
244 244
     
245
-   /**
246
-    * Retrieves the currency of the selected app locale.
247
-    * 
248
-    * @return Localization_Currency
249
-    */
245
+    /**
246
+     * Retrieves the currency of the selected app locale.
247
+     * 
248
+     * @return Localization_Currency
249
+     */
250 250
     public static function getAppCurrency() : Localization_Currency
251 251
     {
252 252
         return self::getCurrencyNS(self::NAMESPACE_APPLICATION);
@@ -283,44 +283,44 @@  discard block
 block discarded – undo
283 283
         return self::getSelectedLocaleByNS(self::NAMESPACE_APPLICATION);
284 284
     }
285 285
     
286
-   /**
287
-    * Retrieves the name of the selected application locale.
288
-    * 
289
-    * @return string
290
-    */
286
+    /**
287
+     * Retrieves the name of the selected application locale.
288
+     * 
289
+     * @return string
290
+     */
291 291
     public static function getAppLocaleName() : string
292 292
     {
293 293
         return self::getLocaleNameByNS(self::NAMESPACE_APPLICATION);
294 294
     }
295 295
     
296
-   /**
297
-    * Retrieves the names of the available application locales.
298
-    * @return string[]
299
-    */
296
+    /**
297
+     * Retrieves the names of the available application locales.
298
+     * @return string[]
299
+     */
300 300
     public static function getAppLocaleNames() : array
301 301
     {
302 302
         return self::getLocaleNamesByNS(self::NAMESPACE_APPLICATION);
303 303
     }
304 304
     
305
-   /**
306
-    * Retrieves the selected locale name in the specified namespace.
307
-    * 
308
-    * @param string $namespace
309
-    * @throws Localization_Exception
310
-    * @return string
311
-    */
305
+    /**
306
+     * Retrieves the selected locale name in the specified namespace.
307
+     * 
308
+     * @param string $namespace
309
+     * @throws Localization_Exception
310
+     * @return string
311
+     */
312 312
     public static function getLocaleNameByNS(string $namespace) : string
313 313
     {
314 314
         return self::getSelectedLocaleByNS($namespace)->getName();
315 315
     }
316 316
     
317
-   /**
318
-    * Retrieves the selected locale instance for the specified namespace.
319
-    * 
320
-    * @param string $namespace
321
-    * @return Localization_Locale
322
-    * @throws Localization_Exception
323
-    */
317
+    /**
318
+     * Retrieves the selected locale instance for the specified namespace.
319
+     * 
320
+     * @param string $namespace
321
+     * @return Localization_Locale
322
+     * @throws Localization_Exception
323
+     */
324 324
     public static function getSelectedLocaleByNS(string $namespace) : Localization_Locale
325 325
     {
326 326
         self::requireNamespace($namespace);
@@ -339,24 +339,24 @@  discard block
 block discarded – undo
339 339
         );
340 340
     }
341 341
     
342
-   /**
343
-    * Stores the selected locale names by namespace.
344
-    * @var array<string,Localization_Locale>
345
-    */
342
+    /**
343
+     * Stores the selected locale names by namespace.
344
+     * @var array<string,Localization_Locale>
345
+     */
346 346
     protected static $selected = array();
347 347
 
348
-   /**
349
-    * Selects the active locale for the specified namespace.
350
-    *
351
-    * NOTE: Triggers the "LocaleChanged" event.
352
-    * 
353
-    * @param string $localeName
354
-    * @param string $namespace
355
-    * @return Localization_Locale
356
-    * @throws Localization_Exception
357
-    *
358
-    * @see Localization_Event_LocaleChanged
359
-    */
348
+    /**
349
+     * Selects the active locale for the specified namespace.
350
+     *
351
+     * NOTE: Triggers the "LocaleChanged" event.
352
+     * 
353
+     * @param string $localeName
354
+     * @param string $namespace
355
+     * @return Localization_Locale
356
+     * @throws Localization_Exception
357
+     *
358
+     * @see Localization_Event_LocaleChanged
359
+     */
360 360
     public static function selectLocaleByNS(string $localeName, string $namespace) : Localization_Locale
361 361
     {
362 362
         self::requireNamespace($namespace);
@@ -487,15 +487,15 @@  discard block
 block discarded – undo
487 487
         return self::selectLocaleByNS($localeName, self::NAMESPACE_APPLICATION);
488 488
     }
489 489
 
490
-   /**
491
-    * Retrieves an application locale by its name. 
492
-    * Note that the locale must have been added first.
493
-    * 
494
-    * @param string $localeName
495
-    * @throws Localization_Exception
496
-    * @return Localization_Locale
497
-    * @see Localization::appLocaleExists()
498
-    */
490
+    /**
491
+     * Retrieves an application locale by its name. 
492
+     * Note that the locale must have been added first.
493
+     * 
494
+     * @param string $localeName
495
+     * @throws Localization_Exception
496
+     * @return Localization_Locale
497
+     * @see Localization::appLocaleExists()
498
+     */
499 499
     public static function getAppLocaleByName(string $localeName) : Localization_Locale
500 500
     {
501 501
         return self::getLocaleByNameNS($localeName, self::NAMESPACE_APPLICATION);
@@ -530,10 +530,10 @@  discard block
 block discarded – undo
530 530
         return self::getLocalesByNS(self::NAMESPACE_CONTENT);
531 531
     }
532 532
     
533
-   /**
534
-    * Retrieves the names of all content locales that have been added.
535
-    * @return string[]
536
-    */
533
+    /**
534
+     * Retrieves the names of all content locales that have been added.
535
+     * @return string[]
536
+     */
537 537
     public static function getContentLocaleNames()
538 538
     {
539 539
         return self::getLocaleNamesByNS(self::NAMESPACE_CONTENT);
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
         sort($names);
557 557
         
558 558
         return $names;
559
-     }
559
+        }
560 560
     
561 561
     /**
562 562
      * Checks by the locale name if the specified locale is
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
         return self::getLocaleByNameNS($localeName, self::NAMESPACE_CONTENT);
586 586
     }
587 587
     
588
-   /**
589
-    * Retrieves a locale by its name in the specified namespace.
590
-    * 
591
-    * @param string $localeName
592
-    * @param string $namespace
593
-    * @throws Localization_Exception
594
-    * @return Localization_Locale
595
-    */
588
+    /**
589
+     * Retrieves a locale by its name in the specified namespace.
590
+     * 
591
+     * @param string $localeName
592
+     * @param string $namespace
593
+     * @throws Localization_Exception
594
+     * @return Localization_Locale
595
+     */
596 596
     public static function getLocaleByNameNS(string $localeName, string $namespace) : Localization_Locale
597 597
     {
598 598
         self::requireNamespace($namespace);
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
         return self::selectLocaleByNS($localeName, self::NAMESPACE_CONTENT);
664 664
     }
665 665
     
666
-   /**
667
-    * Checks whether the localization has been configured entirely.
668
-    * @return bool
669
-    */
666
+    /**
667
+     * Checks whether the localization has been configured entirely.
668
+     * @return bool
669
+     */
670 670
     public static function isConfigured() : bool
671 671
     {
672 672
         return self::$configured;
@@ -738,29 +738,29 @@  discard block
 block discarded – undo
738 738
         );
739 739
     }
740 740
     
741
-   /**
742
-    * Injects a content locales selector element into the specified
743
-    * HTML QuickForm2 container.
744
-    * 
745
-    * @param string $elementName
746
-    * @param HTML_QuickForm2_Container $container
747
-    * @param string $label
748
-    * @return HTML_QuickForm2_Element_Select
749
-    */
741
+    /**
742
+     * Injects a content locales selector element into the specified
743
+     * HTML QuickForm2 container.
744
+     * 
745
+     * @param string $elementName
746
+     * @param HTML_QuickForm2_Container $container
747
+     * @param string $label
748
+     * @return HTML_QuickForm2_Element_Select
749
+     */
750 750
     public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
751 751
     {
752 752
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label);
753 753
     }
754 754
     
755
-   /**
756
-    * Injects an app locales selector element into the specified
755
+    /**
756
+     * Injects an app locales selector element into the specified
757 757
      * HTML QuickForm2 container.
758 758
      * 
759
-    * @param string $elementName
760
-    * @param HTML_QuickForm2_Container $container
761
-    * @param string $label
762
-    * @return HTML_QuickForm2_Element_Select
763
-    */
759
+     * @param string $elementName
760
+     * @param HTML_QuickForm2_Container $container
761
+     * @param string $label
762
+     * @return HTML_QuickForm2_Element_Select
763
+     */
764 764
     public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
765 765
     {
766 766
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label);
@@ -796,26 +796,26 @@  discard block
 block discarded – undo
796 796
         return $select;
797 797
     }
798 798
 
799
-   /**
800
-    * @var Localization_Source[]
801
-    */
799
+    /**
800
+     * @var Localization_Source[]
801
+     */
802 802
     protected static $sources = array();
803 803
     
804
-   /**
805
-    * @var string[]
806
-    */
804
+    /**
805
+     * @var string[]
806
+     */
807 807
     protected static $excludeFolders = array();
808 808
     
809
-   /**
810
-    * @var string[]
811
-    */
809
+    /**
810
+     * @var string[]
811
+     */
812 812
     protected static $excludeFiles = array();
813 813
     
814
-   /**
815
-    * Retrieves all currently available sources.
816
-    * 
817
-    * @return Localization_Source[]
818
-    */
814
+    /**
815
+     * Retrieves all currently available sources.
816
+     * 
817
+     * @return Localization_Source[]
818
+     */
819 819
     public static function getSources() : array
820 820
     {
821 821
         return self::$sources;
@@ -847,10 +847,10 @@  discard block
 block discarded – undo
847 847
         return $source;
848 848
     }
849 849
     
850
-   /**
851
-    * Retrieves all sources grouped by their group name.
852
-    * @return array
853
-    */
850
+    /**
851
+     * Retrieves all sources grouped by their group name.
852
+     * @return array
853
+     */
854 854
     public static function getSourcesGrouped()
855 855
     {
856 856
         $sources = self::getSources();
@@ -871,11 +871,11 @@  discard block
 block discarded – undo
871 871
         return $grouped;
872 872
     }
873 873
     
874
-   /**
875
-    * Checks whether a specific source exists by its ID.
876
-    * @param string $sourceID
877
-    * @return boolean
878
-    */
874
+    /**
875
+     * Checks whether a specific source exists by its ID.
876
+     * @param string $sourceID
877
+     * @return boolean
878
+     */
879 879
     public static function sourceExists(string $sourceID) : bool
880 880
     {
881 881
         $sources = self::getSources();
@@ -888,11 +888,11 @@  discard block
 block discarded – undo
888 888
         return false;
889 889
     }
890 890
     
891
-   /**
892
-    * Checks whether a specific source exists by its alias.
893
-    * @param string $sourceAlias
894
-    * @return boolean
895
-    */
891
+    /**
892
+     * Checks whether a specific source exists by its alias.
893
+     * @param string $sourceAlias
894
+     * @return boolean
895
+     */
896 896
     public static function sourceAliasExists(string $sourceAlias) : bool
897 897
     {
898 898
         $sources = self::getSources();
@@ -905,13 +905,13 @@  discard block
 block discarded – undo
905 905
         return false;
906 906
     }
907 907
 
908
-   /**
909
-    * Retrieves a localization source by its ID.
910
-    * 
911
-    * @param string $sourceID
912
-    * @throws Localization_Exception
913
-    * @return Localization_Source
914
-    */
908
+    /**
909
+     * Retrieves a localization source by its ID.
910
+     * 
911
+     * @param string $sourceID
912
+     * @throws Localization_Exception
913
+     * @return Localization_Source
914
+     */
915 915
     public static function getSourceByID(string $sourceID) : Localization_Source
916 916
     {
917 917
         $sources = self::getSources();
@@ -976,14 +976,14 @@  discard block
 block discarded – undo
976 976
         // FIXME: TODO: Add this
977 977
     }
978 978
     
979
-   /**
980
-    * Configures the localization for the application:
981
-    * sets the location of the required files and folders.
982
-    * Also updated the client library files as needed.
983
-    * 
984
-    * @param string $storageFile Where to store the file analysis storage file.
985
-    * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created.
986
-    */
979
+    /**
980
+     * Configures the localization for the application:
981
+     * sets the location of the required files and folders.
982
+     * Also updated the client library files as needed.
983
+     * 
984
+     * @param string $storageFile Where to store the file analysis storage file.
985
+     * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created.
986
+     */
987 987
     public static function configure(string $storageFile, string $clientLibrariesFolder='') : void
988 988
     {
989 989
         self::$configured = true;
@@ -999,17 +999,17 @@  discard block
 block discarded – undo
999 999
         }
1000 1000
     }
1001 1001
     
1002
-   /**
1003
-    * Sets a key that is used to verify whether the client
1004
-    * libraries have to be refreshed. A common use is to set
1005
-    * this to the application's version number to guarantee
1006
-    * new texts are automatically used with each release.
1007
-    * 
1008
-    * NOTE: Otherwise files are refreshed only when saving 
1009
-    * them in the editor UI.
1010
-    *  
1011
-    * @param string $key
1012
-    */
1002
+    /**
1003
+     * Sets a key that is used to verify whether the client
1004
+     * libraries have to be refreshed. A common use is to set
1005
+     * this to the application's version number to guarantee
1006
+     * new texts are automatically used with each release.
1007
+     * 
1008
+     * NOTE: Otherwise files are refreshed only when saving 
1009
+     * them in the editor UI.
1010
+     *  
1011
+     * @param string $key
1012
+     */
1013 1013
     public static function setClientLibrariesCacheKey(string $key) : void
1014 1014
     {
1015 1015
         self::$clientCacheKey = $key;
@@ -1020,23 +1020,23 @@  discard block
 block discarded – undo
1020 1020
         return self::$clientCacheKey;
1021 1021
     }
1022 1022
     
1023
-   /**
1024
-    * Sets the folder where client libraries are to be stored.
1025
-    * @param string $folder
1026
-    */
1023
+    /**
1024
+     * Sets the folder where client libraries are to be stored.
1025
+     * @param string $folder
1026
+     */
1027 1027
     public static function setClientLibrariesFolder(string $folder) : void
1028 1028
     {
1029 1029
         self::$clientFolder = $folder;
1030 1030
     }
1031 1031
     
1032
-   /**
1033
-    * Retrieves the path to the folder in which the client
1034
-    * libraries should be stored.
1035
-    * 
1036
-    * NOTE: Can return an empty string, when this is disabled.
1037
-    * 
1038
-    * @return string
1039
-    */
1032
+    /**
1033
+     * Retrieves the path to the folder in which the client
1034
+     * libraries should be stored.
1035
+     * 
1036
+     * NOTE: Can return an empty string, when this is disabled.
1037
+     * 
1038
+     * @return string
1039
+     */
1040 1040
     public static function getClientLibrariesFolder() : string
1041 1041
     {
1042 1042
         return self::$clientFolder;
@@ -1056,13 +1056,13 @@  discard block
 block discarded – undo
1056 1056
         self::createGenerator()->writeFiles($force);
1057 1057
     }
1058 1058
     
1059
-   /**
1060
-    * Creates a new instance of the client generator class
1061
-    * that is used to write the localization files into the
1062
-    * target folder on disk.
1063
-    * 
1064
-    * @return Localization_ClientGenerator
1065
-    */
1059
+    /**
1060
+     * Creates a new instance of the client generator class
1061
+     * that is used to write the localization files into the
1062
+     * target folder on disk.
1063
+     * 
1064
+     * @return Localization_ClientGenerator
1065
+     */
1066 1066
     public static function createGenerator() : Localization_ClientGenerator
1067 1067
     {
1068 1068
         return new Localization_ClientGenerator();
@@ -1127,10 +1127,10 @@  discard block
 block discarded – undo
1127 1127
         return new Localization_Editor();
1128 1128
     }
1129 1129
     
1130
-   /**
1131
-    * Retrieves a list of all available source IDs.
1132
-    * @return string[]
1133
-    */
1130
+    /**
1131
+     * Retrieves a list of all available source IDs.
1132
+     * @return string[]
1133
+     */
1134 1134
     public static function getSourceIDs() : array
1135 1135
     {
1136 1136
         $ids = array();
@@ -1157,9 +1157,9 @@  discard block
 block discarded – undo
1157 1157
         return $aliases;
1158 1158
     }
1159 1159
     
1160
-   /**
1161
-    * Resets all locales to the built-in locale.
1162
-    */
1160
+    /**
1161
+     * Resets all locales to the built-in locale.
1162
+     */
1163 1163
     public static function reset() : void
1164 1164
     {
1165 1165
         self::$locales = array();
@@ -1191,22 +1191,22 @@  discard block
 block discarded – undo
1191 1191
         'de_CH'
1192 1192
     );
1193 1193
     
1194
-   /**
1195
-    * Retrieves a list of all supported locales.
1196
-    * 
1197
-    * @return string[]
1198
-    */
1194
+    /**
1195
+     * Retrieves a list of all supported locales.
1196
+     * 
1197
+     * @return string[]
1198
+     */
1199 1199
     public static function getSupportedLocaleNames() : array
1200 1200
     {
1201 1201
         return self::$supportedLocales;
1202 1202
     }
1203 1203
     
1204
-   /**
1205
-    * Checks whether the specified locale is supported.
1206
-    * 
1207
-    * @param string $localeName
1208
-    * @return bool
1209
-    */
1204
+    /**
1205
+     * Checks whether the specified locale is supported.
1206
+     * 
1207
+     * @param string $localeName
1208
+     * @return bool
1209
+     */
1210 1210
     public static function isLocaleSupported(string $localeName) : bool
1211 1211
     {
1212 1212
         return in_array($localeName, self::$supportedLocales);
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     */
115 115
     public static function init() : void
116 116
     {
117
-        if(self::$initDone) {
117
+        if (self::$initDone) {
118 118
             return;
119 119
         }
120 120
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     */
159 159
     public static function getLocalesByNS(string $namespace)
160 160
     {
161
-        if(isset(self::$locales[$namespace])) {
161
+        if (isset(self::$locales[$namespace])) {
162 162
             return array_values(self::$locales[$namespace]);
163 163
         }
164 164
         
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
     */
204 204
     public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale
205 205
     {
206
-        if(!isset(self::$locales[$namespace])) {
206
+        if (!isset(self::$locales[$namespace])) {
207 207
             self::$locales[$namespace] = array();
208 208
         }
209 209
         
210
-        if(!isset(self::$locales[$namespace][$localeName])) 
210
+        if (!isset(self::$locales[$namespace][$localeName])) 
211 211
         {
212 212
             self::$locales[$namespace][$localeName] = self::createLocale($localeName);
213 213
             
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public static function createCountry(string $id)
240 240
     {
241
-        $className = '\AppLocalize\Localization_Country_' . strtoupper($id);
241
+        $className = '\AppLocalize\Localization_Country_'.strtoupper($id);
242 242
         return new $className();
243 243
     }
244 244
     
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
     {
326 326
         self::requireNamespace($namespace);
327 327
         
328
-        if(isset(self::$selected[$namespace])) {
328
+        if (isset(self::$selected[$namespace])) {
329 329
             return self::$selected[$namespace];
330 330
         }
331 331
         
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
         $locale = self::addLocaleByNS($localeName, $namespace);
365 365
         $previous = null;
366 366
         
367
-        if(isset(self::$selected[$namespace])) 
367
+        if (isset(self::$selected[$namespace])) 
368 368
         {
369
-            if(self::$selected[$namespace]->getName() === $localeName) {
369
+            if (self::$selected[$namespace]->getName() === $localeName) {
370 370
                 return $locale;
371 371
             }
372 372
             
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
         $class = Localization_Event::class.'_'.$name;
403 403
         $event = new $class($argsList);
404 404
         
405
-        if(!isset(self::$listeners[$name])) {
405
+        if (!isset(self::$listeners[$name])) {
406 406
             return $event;
407 407
         }
408 408
         
409
-        foreach(self::$listeners[$name] as $listener) 
409
+        foreach (self::$listeners[$name] as $listener) 
410 410
         {
411 411
             $callArgs = $listener['args'];
412 412
             array_unshift($callArgs, $event);
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
      * @throws Localization_Exception
429 429
      * @see \AppLocalize\Localization::ERROR_UNKNOWN_EVENT_NAME
430 430
      */
431
-    public static function addEventListener(string $eventName, $callback, array $args=array()) : int
431
+    public static function addEventListener(string $eventName, $callback, array $args = array()) : int
432 432
     {
433
-        if(!isset(self::$listeners[$eventName])) {
433
+        if (!isset(self::$listeners[$eventName])) {
434 434
             self::$listeners[$eventName] = array();
435 435
         }
436 436
         
437 437
         $className = Localization_Event::class.'_'.$eventName;
438 438
         
439
-        if(!class_exists($className)) 
439
+        if (!class_exists($className)) 
440 440
         {
441 441
             throw new Localization_Exception(
442 442
                 sprintf('Unknown localization event [%s].', $eventName),
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
      * @throws Localization_Exception
471 471
      * @see Localization_Event_LocaleChanged
472 472
      */
473
-    public static function onLocaleChanged($callback, array $args=array()) : int
473
+    public static function onLocaleChanged($callback, array $args = array()) : int
474 474
     {
475 475
         return self::addEventListener(self::EVENT_LOCALE_CHANGED, $callback, $args);
476 476
     }
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
     {
598 598
         self::requireNamespace($namespace);
599 599
         
600
-        if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) {
600
+        if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) {
601 601
             return self::$locales[$namespace][$localeName];
602 602
         }
603 603
         
@@ -676,9 +676,9 @@  discard block
 block discarded – undo
676 676
      * @param Localization_Locale|null $locale
677 677
      * @return Localization_Translator
678 678
      */
679
-    public static function getTranslator(?Localization_Locale $locale=null) : Localization_Translator
679
+    public static function getTranslator(?Localization_Locale $locale = null) : Localization_Translator
680 680
     {
681
-        if($locale !== null)
681
+        if ($locale !== null)
682 682
         {
683 683
             $obj = new Localization_Translator();
684 684
             $obj->addSources(self::getSources());
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
             return $obj;
687 687
         }
688 688
             
689
-        if(!isset(self::$translator)) 
689
+        if (!isset(self::$translator)) 
690 690
         {
691 691
             $obj = new Localization_Translator();
692 692
             $obj->addSources(self::getSources());
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
     {
712 712
         self::requireNamespace($namespace);
713 713
         
714
-        if(isset(self::$locales[$namespace])) {
714
+        if (isset(self::$locales[$namespace])) {
715 715
             return count(self::$locales[$namespace]);
716 716
         }
717 717
         
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
      */
725 725
     protected static function requireNamespace(string $namespace) : void
726 726
     {
727
-        if(isset(self::$locales[$namespace])) {
727
+        if (isset(self::$locales[$namespace])) {
728 728
             return;
729 729
         }
730 730
         
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
     * @param string $label
748 748
     * @return HTML_QuickForm2_Element_Select
749 749
     */
750
-    public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
750
+    public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
751 751
     {
752 752
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label);
753 753
     }
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
     * @param string $label
762 762
     * @return HTML_QuickForm2_Element_Select
763 763
     */
764
-    public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
764
+    public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
765 765
     {
766 766
         return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label);
767 767
     }
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
      * @return HTML_QuickForm2_Element_Select
779 779
      * @throws Localization_Exception
780 780
      */
781
-    public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select
781
+    public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select
782 782
     {
783
-        if(empty($label)) {
783
+        if (empty($label)) {
784 784
             $label = t('Language');
785 785
         }
786 786
 
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 
790 790
         $locales = self::getLocalesByNS($namespace);
791 791
         
792
-        foreach($locales as $locale) {
792
+        foreach ($locales as $locale) {
793 793
             $select->addOption($locale->getLabel(), $locale->getName());
794 794
         }
795 795
 
@@ -823,14 +823,14 @@  discard block
 block discarded – undo
823 823
     
824 824
     public static function addExcludeFolder(string $folderName) : void
825 825
     { 
826
-        if(!in_array($folderName, self::$excludeFolders)) {
826
+        if (!in_array($folderName, self::$excludeFolders)) {
827 827
             self::$excludeFolders[] = $folderName;
828 828
         }
829 829
     }
830 830
     
831 831
     public static function addExcludeFile(string $fileName) : void
832 832
     {
833
-        if(!in_array($fileName, self::$excludeFiles)) {
833
+        if (!in_array($fileName, self::$excludeFiles)) {
834 834
             self::$excludeFiles[] = $fileName;
835 835
         }
836 836
     }
@@ -857,11 +857,11 @@  discard block
 block discarded – undo
857 857
         
858 858
         $grouped = array();
859 859
         
860
-        foreach($sources as $source) 
860
+        foreach ($sources as $source) 
861 861
         {
862 862
             $group = $source->getGroup();
863 863
             
864
-            if(!isset($grouped[$group])) {
864
+            if (!isset($grouped[$group])) {
865 865
                 $grouped[$group] = array();
866 866
             }
867 867
             
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
     public static function sourceExists(string $sourceID) : bool
880 880
     {
881 881
         $sources = self::getSources();
882
-        foreach($sources as $source) {
883
-            if($source->getID() == $sourceID) {
882
+        foreach ($sources as $source) {
883
+            if ($source->getID() == $sourceID) {
884 884
                 return true;
885 885
             }
886 886
         }
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
     public static function sourceAliasExists(string $sourceAlias) : bool
897 897
     {
898 898
         $sources = self::getSources();
899
-        foreach($sources as $source) {
900
-            if($source->getAlias() == $sourceAlias) {
899
+        foreach ($sources as $source) {
900
+            if ($source->getAlias() == $sourceAlias) {
901 901
                 return true;
902 902
             }
903 903
         }
@@ -915,8 +915,8 @@  discard block
 block discarded – undo
915 915
     public static function getSourceByID(string $sourceID) : Localization_Source
916 916
     {
917 917
         $sources = self::getSources();
918
-        foreach($sources as $source) {
919
-            if($source->getID() == $sourceID) {
918
+        foreach ($sources as $source) {
919
+            if ($source->getID() == $sourceID) {
920 920
                 return $source;
921 921
             }
922 922
         }
@@ -941,8 +941,8 @@  discard block
 block discarded – undo
941 941
     public static function getSourceByAlias(string $sourceAlias) : Localization_Source
942 942
     {
943 943
         $sources = self::getSources();
944
-        foreach($sources as $source) {
945
-            if($source->getAlias() == $sourceAlias) {
944
+        foreach ($sources as $source) {
945
+            if ($source->getAlias() == $sourceAlias) {
946 946
                 return $source;
947 947
             }
948 948
         }
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
     * @param string $storageFile Where to store the file analysis storage file.
985 985
     * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created.
986 986
     */
987
-    public static function configure(string $storageFile, string $clientLibrariesFolder='') : void
987
+    public static function configure(string $storageFile, string $clientLibrariesFolder = '') : void
988 988
     {
989 989
         self::$configured = true;
990 990
         
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 
994 994
         // only write the client libraries to disk if the folder
995 995
         // has been specified.
996
-        if(!empty($clientLibrariesFolder)) 
996
+        if (!empty($clientLibrariesFolder)) 
997 997
         {
998 998
             self::writeClientFiles();
999 999
         }
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
      * @throws Localization_Exception
1052 1052
      * @see Localization_ClientGenerator
1053 1053
      */
1054
-    public static function writeClientFiles(bool $force=false) : void
1054
+    public static function writeClientFiles(bool $force = false) : void
1055 1055
     {
1056 1056
         self::createGenerator()->writeFiles($force);
1057 1057
     }
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
      */
1085 1085
     protected static function requireConfiguration() : void
1086 1086
     {
1087
-        if(!self::$configured) 
1087
+        if (!self::$configured) 
1088 1088
         {
1089 1089
             throw new Localization_Exception(
1090 1090
                 'The localization configuration is incomplete.',
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
             );
1094 1094
         }
1095 1095
 
1096
-        if(empty(self::$storageFile))
1096
+        if (empty(self::$storageFile))
1097 1097
         {
1098 1098
             throw new Localization_Exception(
1099 1099
                 'No localization storage file set',
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
             );
1103 1103
         }
1104 1104
         
1105
-        if(empty(self::$sources)) 
1105
+        if (empty(self::$sources)) 
1106 1106
         {
1107 1107
             throw new Localization_Exception(
1108 1108
                 'No source folders have been defined.',
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
     {
1136 1136
         $ids = array();
1137 1137
         
1138
-        foreach(self::$sources as $source) {
1138
+        foreach (self::$sources as $source) {
1139 1139
             $ids[] = $source->getID();
1140 1140
         }
1141 1141
         
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
     {
1151 1151
         $aliases = array();
1152 1152
         
1153
-        foreach(self::$sources as $source) {
1153
+        foreach (self::$sources as $source) {
1154 1154
             $aliases[] = $source->getAlias();
1155 1155
         }
1156 1156
         
Please login to merge, or discard this patch.
src/Localization/Source/Folder.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,24 +9,24 @@
 block discarded – undo
9 9
 
10 10
 class Localization_Source_Folder extends Localization_Source
11 11
 {
12
-   /**
13
-    * The folder under which all translatable files are kept.
14
-    * @var string
15
-    */
12
+    /**
13
+     * The folder under which all translatable files are kept.
14
+     * @var string
15
+     */
16 16
     protected $sourcesFolder;
17 17
     
18
-   /**
19
-    * @var string
20
-    */
18
+    /**
19
+     * @var string
20
+     */
21 21
     protected $id;
22 22
 
23
-   /**
24
-    * @param string $alias An alias for this source, to recognize it by.
25
-    * @param string $label The human-readable label, used in the editor.
26
-    * @param string $group A human-readable group label to group several sources by. Used in the editor.
27
-    * @param string $storageFolder The folder in which to store the localization files.
28
-    * @param string $sourcesFolder The folder in which to analyze files to find translatable strings.
29
-    */
23
+    /**
24
+     * @param string $alias An alias for this source, to recognize it by.
25
+     * @param string $label The human-readable label, used in the editor.
26
+     * @param string $group A human-readable group label to group several sources by. Used in the editor.
27
+     * @param string $storageFolder The folder in which to store the localization files.
28
+     * @param string $sourcesFolder The folder in which to analyze files to find translatable strings.
29
+     */
30 30
     public function __construct(string $alias, string $label, string $group, string $storageFolder, string $sourcesFolder)
31 31
     {
32 32
         parent::__construct($alias, $label, $group, $storageFolder);
Please login to merge, or discard this patch.
src/Localization/Currency/Number.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
      */
55 55
     public function getFloat() : float
56 56
     {
57
-        return floatval($this->number . '.' . $this->decimals);
57
+        return floatval($this->number.'.'.$this->decimals);
58 58
     }
59 59
 
60 60
     /**
Please login to merge, or discard this patch.
src/Localization/Source.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 
7 7
 abstract class Localization_Source
8 8
 {
9
-   /**
10
-    * Human-readable label for the source.
11
-    * @var string
12
-    */
9
+    /**
10
+     * Human-readable label for the source.
11
+     * @var string
12
+     */
13 13
     protected $label;
14 14
     
15
-   /**
16
-    * Human-readable group name to categorize the source.
17
-    * @var string
18
-    */
15
+    /**
16
+     * Human-readable group name to categorize the source.
17
+     * @var string
18
+     */
19 19
     protected $group;
20 20
     
21
-   /**
22
-    * The folder in which the localization files are stored
23
-    * @var string
24
-    */
21
+    /**
22
+     * The folder in which the localization files are stored
23
+     * @var string
24
+     */
25 25
     protected $storageFolder;
26 26
     
27
-   /**
28
-    * @var string
29
-    */
27
+    /**
28
+     * @var string
29
+     */
30 30
     protected $alias;
31 31
     
32
-   /**
33
-    * Available during scanning.
34
-    * @var Localization_Scanner_StringsCollection|NULL
35
-    */
32
+    /**
33
+     * Available during scanning.
34
+     * @var Localization_Scanner_StringsCollection|NULL
35
+     */
36 36
     protected $collection;
37 37
     
38
-   /**
39
-    * Available during scanning.
40
-    * @var Localization_Parser|NULL
41
-    */
38
+    /**
39
+     * Available during scanning.
40
+     * @var Localization_Parser|NULL
41
+     */
42 42
     protected $parser;
43 43
     
44 44
     public function __construct(string $alias, string $label, string $group, string $storageFolder)
Please login to merge, or discard this patch.
src/Localization/Parser.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
     const ERROR_UNSUPPORTED_FILE_EXTENSION = 40602;
31 31
     const ERROR_INVALID_LANGUAGE_CLASS = 40603;
32 32
     
33
-   /**
34
-    * @var Localization_Scanner
35
-    */
33
+    /**
34
+     * @var Localization_Scanner
35
+     */
36 36
     protected $scanner;
37 37
     
38
-   /**
39
-    * @var Localization_Scanner_StringsCollection
40
-    */
38
+    /**
39
+     * @var Localization_Scanner_StringsCollection
40
+     */
41 41
     protected $collection;
42 42
 
43 43
     /**
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
         $this->collection = $scanner->getCollection();
55 55
     }
56 56
     
57
-   /**
58
-    * Parses a source file. Must have a valid supported file extension.
59
-    * 
60
-    * @param string $path
61
-    * @return Localization_Parser_Language
62
-    * @throws Localization_Exception
63
-    * 
64
-    * @see Localization_Parser::ERROR_UNSUPPORTED_FILE_EXTENSION
65
-    */
57
+    /**
58
+     * Parses a source file. Must have a valid supported file extension.
59
+     * 
60
+     * @param string $path
61
+     * @return Localization_Parser_Language
62
+     * @throws Localization_Exception
63
+     * 
64
+     * @see Localization_Parser::ERROR_UNSUPPORTED_FILE_EXTENSION
65
+     */
66 66
     public function parseFile(string $path) : Localization_Parser_Language
67 67
     {
68 68
         $this->requireValidFile($path);
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
         return $language;
77 77
     }
78 78
     
79
-   /**
80
-    * Parses the string for the specified language.
81
-    * 
82
-    * @param string $languageID
83
-    * @param string $code
84
-    * @return Localization_Parser_Language
85
-    * @throws Localization_Exception
86
-    * 
87
-    * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID
88
-    */
79
+    /**
80
+     * Parses the string for the specified language.
81
+     * 
82
+     * @param string $languageID
83
+     * @param string $code
84
+     * @return Localization_Parser_Language
85
+     * @throws Localization_Exception
86
+     * 
87
+     * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID
88
+     */
89 89
     public function parseString(string $languageID, string $code) : Localization_Parser_Language
90 90
     {
91 91
         $this->requireValidLanguageID($languageID);
@@ -144,18 +144,18 @@  discard block
 block discarded – undo
144 144
         );
145 145
     }
146 146
     
147
-   /**
148
-    * Retrieves a list of all language IDs that are supported.
149
-    * @return string[] IDs list like "PHP", "Javascript"
150
-    */
147
+    /**
148
+     * Retrieves a list of all language IDs that are supported.
149
+     * @return string[] IDs list like "PHP", "Javascript"
150
+     */
151 151
     public function getLanguageIDs() : array
152 152
     {
153 153
         return array_values($this->languageMappings);
154 154
     }
155 155
     
156
-   /**
157
-    * @var array<string,Localization_Parser_Language>
158
-    */
156
+    /**
157
+     * @var array<string,Localization_Parser_Language>
158
+     */
159 159
     protected $languageParsers = array();
160 160
 
161 161
     /**
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
         );
210 210
     }
211 211
 
212
-   /**
213
-    * Whether the specified file extension is supported.
214
-    * 
215
-    * @param string $ext
216
-    * @return bool
217
-    */
212
+    /**
213
+     * Whether the specified file extension is supported.
214
+     * 
215
+     * @param string $ext
216
+     * @return bool
217
+     */
218 218
     public function isExtensionSupported(string $ext) : bool
219 219
     {
220 220
         $ext = strtolower($ext);
Please login to merge, or discard this patch.
src/Localization/Translator.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
     protected $reverseStrings = array();
58 58
 
59 59
     /**
60
-    * @var Localization_Source[]
61
-    */
60
+     * @var Localization_Source[]
61
+     */
62 62
     private $sources = array();
63 63
 
64 64
     /**
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
         );
192 192
     }
193 193
     
194
-   /**
195
-    * Retrieves all available strings for the specified locale,
196
-    * as hash => text value pairs.
197
-    * 
198
-    * @param Localization_Locale $locale
199
-    * @throws Localization_Exception
200
-    * @return string[]
201
-    */
194
+    /**
195
+     * Retrieves all available strings for the specified locale,
196
+     * as hash => text value pairs.
197
+     * 
198
+     * @param Localization_Locale $locale
199
+     * @throws Localization_Exception
200
+     * @return string[]
201
+     */
202 202
     public function getStrings(Localization_Locale $locale) : array
203 203
     {
204 204
         $this->load($locale);
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public function addSources(array $sources) : void
81 81
     {
82
-        foreach($sources as $source) {
82
+        foreach ($sources as $source) {
83 83
             $this->addSource($source);
84 84
         }
85 85
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             $this->strings[$localeName] = array();
125 125
         }
126 126
 
127
-        foreach($this->sources as $source)
127
+        foreach ($this->sources as $source)
128 128
         {
129 129
             $file = $this->resolveStorageFile($locale, $source);
130 130
             if (!file_exists($file)) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             
134 134
             $data = parse_ini_file($file, false);
135 135
             
136
-            if($data === false) 
136
+            if ($data === false) 
137 137
             {
138 138
                 throw new Localization_Exception(
139 139
                     'Malformatted localization file',
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         
206 206
         $name = $locale->getName();
207 207
         
208
-        if(isset($this->strings[$name])) {
208
+        if (isset($this->strings[$name])) {
209 209
             return $this->strings[$name];
210 210
         }
211 211
         
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
      * @param Localization_Locale $locale
241 241
      * @param boolean $editable
242 242
      */
243
-    protected function renderStringsFile(string $type, Localization_Source $source, array $hashes, string $file, Localization_Locale $locale, bool $editable=true) : void
243
+    protected function renderStringsFile(string $type, Localization_Source $source, array $hashes, string $file, Localization_Locale $locale, bool $editable = true) : void
244 244
     {
245 245
         $writer = new Localization_Writer($locale, $type, $file);
246 246
 
247
-        if($editable)
247
+        if ($editable)
248 248
         {
249 249
             $writer->makeEditable();
250 250
         }
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
         
254 254
         foreach ($hashes as $hash) 
255 255
         {
256
-            if(!$hash->hasSourceID($sourceID)) {
256
+            if (!$hash->hasSourceID($sourceID)) {
257 257
                 continue;
258 258
             }
259 259
             
260 260
             $text = $this->getHashTranslation($hash->getHash(), $locale);
261 261
 
262 262
             // skip any empty strings
263
-            if($text === null || trim($text) == '') {
263
+            if ($text === null || trim($text) == '') {
264 264
                 continue;
265 265
             }
266 266
             
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
     {
339 339
         // to avoid re-creating the hash for the same texts over and over,
340 340
         // we keep track of the hashes we created, and re-use them.
341
-        if(isset($this->reverseStrings[$text])) {
341
+        if (isset($this->reverseStrings[$text])) {
342 342
             $hash = $this->reverseStrings[$text];
343 343
         } else {
344 344
             $hash = md5($text);
@@ -403,15 +403,15 @@  discard block
 block discarded – undo
403 403
      * @param Localization_Locale|null $locale
404 404
      * @return string|NULL
405 405
      */
406
-    public function getHashTranslation(string $hash, ?Localization_Locale $locale=null) : ?string
406
+    public function getHashTranslation(string $hash, ?Localization_Locale $locale = null) : ?string
407 407
     {
408
-        if(!$locale) {
408
+        if (!$locale) {
409 409
             $locale = $this->targetLocale;
410 410
         }
411 411
         
412 412
         $localeName = $locale->getName();
413 413
         
414
-        if(isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) {
414
+        if (isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) {
415 415
             return $this->strings[$localeName][$hash];
416 416
         }
417 417
 
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
     {
430 430
         $result = array();
431 431
         
432
-        foreach($this->sources as $source) 
432
+        foreach ($this->sources as $source) 
433 433
         {
434 434
             $localeFile = self::getClientStorageFile($locale, $source);
435
-            if(!file_exists($localeFile)) {
435
+            if (!file_exists($localeFile)) {
436 436
                 continue;
437 437
             }
438 438
 
Please login to merge, or discard this patch.
src/Localization/Parser/Token.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@  discard block
 block discarded – undo
8 8
 
9 9
 abstract class Localization_Parser_Token
10 10
 {
11
-   /**
12
-    * @var array|string
13
-    */
11
+    /**
12
+     * @var array|string
13
+     */
14 14
     protected $definition;
15 15
     
16
-   /**
17
-    * @var Localization_Parser_Token
18
-    */
16
+    /**
17
+     * @var Localization_Parser_Token
18
+     */
19 19
     protected $parentToken;
20 20
 
21 21
     /**
@@ -98,6 +98,6 @@  discard block
 block discarded – undo
98 98
             'value' => $this->getValue(),
99 99
             'line' => $this->getLine(),
100 100
             'isEncapsedString' => ConvertHelper::bool2string($this->isEncapsedString())
101
-         );
101
+            );
102 102
     }
103 103
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@
 block discarded – undo
42 42
      * @param array|string $definition
43 43
      * @param Localization_Parser_Token|null $parentToken
44 44
      */
45
-    public function __construct($definition, ?Localization_Parser_Token $parentToken=null)
45
+    public function __construct($definition, ?Localization_Parser_Token $parentToken = null)
46 46
     {
47 47
         $this->definition = $definition;
48 48
         $this->parentToken = $parentToken;
49 49
 
50 50
         $names = $this->getFunctionNames();
51
-        foreach($names as $name) {
51
+        foreach ($names as $name) {
52 52
             $this->nameLookup[$name] = true;
53 53
         }
54 54
 
Please login to merge, or discard this patch.
src/Localization/Parser/Language.php 3 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -23,49 +23,49 @@  discard block
 block discarded – undo
23 23
      */
24 24
     protected $parser;
25 25
 
26
-   /**
27
-    * The function names that are included in the search.
28
-    * @var array
29
-    */
26
+    /**
27
+     * The function names that are included in the search.
28
+     * @var array
29
+     */
30 30
     protected $functionNames = array();
31 31
     
32
-   /**
33
-    * The tokens definitions.
34
-    * @var array
35
-    */
32
+    /**
33
+     * The tokens definitions.
34
+     * @var array
35
+     */
36 36
     protected $tokens = array();
37 37
     
38
-   /**
39
-    * The total amount of tokens found in the content.
40
-    * @var integer
41
-    */
38
+    /**
39
+     * The total amount of tokens found in the content.
40
+     * @var integer
41
+     */
42 42
     protected $totalTokens = 0;
43 43
     
44
-   /**
45
-    * All texts that have been collected.
46
-    * @var Text[]
47
-    */
44
+    /**
45
+     * All texts that have been collected.
46
+     * @var Text[]
47
+     */
48 48
     protected $texts = array();
49 49
     
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected $content = '';
54 54
 
55
-   /**
56
-    * @var string|NULL
57
-    */
55
+    /**
56
+     * @var string|NULL
57
+     */
58 58
     protected $id;
59 59
     
60
-   /**
61
-    * @var Localization_Parser_Warning[]
62
-    */
60
+    /**
61
+     * @var Localization_Parser_Warning[]
62
+     */
63 63
     protected $warnings = array();
64 64
     
65
-   /**
66
-    * The source file that was parsed (if any)
67
-    * @var string
68
-    */
65
+    /**
66
+     * The source file that was parsed (if any)
67
+     * @var string
68
+     */
69 69
     protected $sourceFile = '';
70 70
     
71 71
     public function __construct(Localization_Parser $parser)
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
     
77 77
     abstract protected function getTokens() : array;
78 78
     
79
-   /**
80
-    * Retrieves the ID of the language.
81
-    * @return string E.g. "PHP", "Javascript"
82
-    */
79
+    /**
80
+     * Retrieves the ID of the language.
81
+     * @return string E.g. "PHP", "Javascript"
82
+     */
83 83
     public function getID() : string
84 84
     {
85 85
         if(!isset($this->id)) {
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
         return $this->sourceFile;
100 100
     }
101 101
     
102
-   /**
103
-    * Parses the code from a file.
104
-    * 
105
-    * @param string $path
106
-    * @throws Localization_Exception
107
-    */
102
+    /**
103
+     * Parses the code from a file.
104
+     * 
105
+     * @param string $path
106
+     * @throws Localization_Exception
107
+     */
108 108
     public function parseFile(string $path) : void
109 109
     {
110 110
         if(!file_exists($path)) 
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
         $this->parse();
142 142
     }
143 143
     
144
-   /**
145
-    * Parses a source code string.
146
-    * @param string $content
147
-    */
144
+    /**
145
+     * Parses a source code string.
146
+     * @param string $content
147
+     */
148 148
     public function parseString(string $content) : void
149 149
     {
150 150
         $this->content = $content;
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
         $this->texts[] = new Text($text, $line, $explanation);
186 186
     }
187 187
 
188
-   /**
189
-    * Retrieves a list of all the function names that are
190
-    * used as translation functions in the language.
191
-    * @return array
192
-    */
188
+    /**
189
+     * Retrieves a list of all the function names that are
190
+     * used as translation functions in the language.
191
+     * @return array
192
+     */
193 193
     public function getFunctionNames() : array
194 194
     {
195 195
         return $this->createToken('dummy')->getFunctionNames();
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
         Localization::log(sprintf('%1$s parser | %2$s', $this->getID(), $message));
201 201
     }
202 202
 
203
-   /**
204
-    * Adds a warning message when a text cannot be parsed correctly for some reason.
205
-    * 
206
-    * @param Localization_Parser_Token $token
207
-    * @param string $message
208
-    * @return Localization_Parser_Warning
209
-    */
203
+    /**
204
+     * Adds a warning message when a text cannot be parsed correctly for some reason.
205
+     * 
206
+     * @param Localization_Parser_Token $token
207
+     * @param string $message
208
+     * @return Localization_Parser_Warning
209
+     */
210 210
     protected function addWarning(Localization_Parser_Token $token, string $message) : Localization_Parser_Warning
211 211
     {
212 212
         $warning = new Localization_Parser_Warning($this, $token, $message);
@@ -216,34 +216,34 @@  discard block
 block discarded – undo
216 216
         return $warning;
217 217
     }
218 218
     
219
-   /**
220
-    * Whether any warnings were generated during parsing.
221
-    * @return bool
222
-    */
219
+    /**
220
+     * Whether any warnings were generated during parsing.
221
+     * @return bool
222
+     */
223 223
     public function hasWarnings() : bool
224 224
     {
225 225
         return !empty($this->warnings);
226 226
     }
227 227
     
228
-   /**
229
-    * Retrieves all warnings that were generated during parsing,
230
-    * if any.
231
-    * 
232
-    * @return Localization_Parser_Warning[]
233
-    */
228
+    /**
229
+     * Retrieves all warnings that were generated during parsing,
230
+     * if any.
231
+     * 
232
+     * @return Localization_Parser_Warning[]
233
+     */
234 234
     public function getWarnings() : array
235 235
     {
236 236
         return $this->warnings;
237 237
     }
238 238
     
239
-   /**
240
-    * Creates a token instance: this retrieves information on
241
-    * the language token being parsed.
242
-    * 
243
-    * @param array|string $definition The token definition.
244
-    * @param Localization_Parser_Token|NULL $parentToken
245
-    * @return Localization_Parser_Token
246
-    */
239
+    /**
240
+     * Creates a token instance: this retrieves information on
241
+     * the language token being parsed.
242
+     * 
243
+     * @param array|string $definition The token definition.
244
+     * @param Localization_Parser_Token|NULL $parentToken
245
+     * @return Localization_Parser_Token
246
+     */
247 247
     protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token
248 248
     {
249 249
         $class = Localization_Parser_Token::class.'_'.$this->getID();
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
         return new $class($definition, $parentToken);
252 252
     }
253 253
 
254
-   /**
255
-    * Parses a translation function token.
256
-    * 
257
-    * @param int $number
258
-    * @param Localization_Parser_Token $token
259
-    */
254
+    /**
255
+     * Parses a translation function token.
256
+     * 
257
+     * @param int $number
258
+     * @param Localization_Parser_Token $token
259
+     */
260 260
     protected function parseToken(int $number, Localization_Parser_Token $token) : void
261 261
     {
262 262
         $textParts = array();
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     */
83 83
     public function getID() : string
84 84
     {
85
-        if(!isset($this->id)) {
85
+        if (!isset($this->id)) {
86 86
             $this->id = str_replace(Localization_Parser_Language::class.'_', '', get_class($this));
87 87
         }
88 88
         
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     */
108 108
     public function parseFile(string $path) : void
109 109
     {
110
-        if(!file_exists($path)) 
110
+        if (!file_exists($path)) 
111 111
         {
112 112
             throw new Localization_Exception(
113 113
                 sprintf('Source code file [%s] not found', basename($path)),
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
         $this->tokens = $this->getTokens();
161 161
         $this->totalTokens = count($this->tokens);
162 162
         
163
-        for($i = 0; $i < $this->totalTokens; $i++)
163
+        for ($i = 0; $i < $this->totalTokens; $i++)
164 164
         {
165 165
             $token = $this->createToken($this->tokens[$i]);
166 166
             
167
-            if($token->isTranslationFunction()) {
168
-                $this->parseToken($i+1, $token);
167
+            if ($token->isTranslationFunction()) {
168
+                $this->parseToken($i + 1, $token);
169 169
             }
170 170
         }
171 171
     }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         return $this->texts;
179 179
     }
180 180
     
181
-    protected function addResult(string $text, int $line=0, string $explanation='') : void
181
+    protected function addResult(string $text, int $line = 0, string $explanation = '') : void
182 182
     {
183 183
         $this->log(sprintf('Line [%1$s] | Found string [%2$s]', $line, $text));
184 184
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     * @param Localization_Parser_Token|NULL $parentToken
245 245
     * @return Localization_Parser_Token
246 246
     */
247
-    protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token
247
+    protected function createToken($definition, Localization_Parser_Token $parentToken = null) : Localization_Parser_Token
248 248
     {
249 249
         $class = Localization_Parser_Token::class.'_'.$this->getID();
250 250
         
@@ -264,48 +264,48 @@  discard block
 block discarded – undo
264 264
         $open = false;
265 265
         $explanation = '';
266 266
         
267
-        for($i = $number; $i < $max; $i++)
267
+        for ($i = $number; $i < $max; $i++)
268 268
         {
269
-            if(!isset($this->tokens[$i])) {
269
+            if (!isset($this->tokens[$i])) {
270 270
                 break;
271 271
             }
272 272
             
273 273
             $subToken = $this->createToken($this->tokens[$i], $token);
274 274
             
275
-            if(!$open && $subToken->isOpeningFuncParams())
275
+            if (!$open && $subToken->isOpeningFuncParams())
276 276
             {
277 277
                 $open = true;
278 278
                 continue;
279 279
             }
280 280
             
281
-            if($open && $subToken->isClosingFuncParams()) {
281
+            if ($open && $subToken->isClosingFuncParams()) {
282 282
                 break;
283 283
             }
284 284
             
285 285
             // additional parameters in the translation function, we don't want to capture these now.
286
-            if($open && $subToken->isArgumentSeparator())
286
+            if ($open && $subToken->isArgumentSeparator())
287 287
             {
288
-                if($token->isExplanationFunction()) {
289
-                    $leftover = array_slice($this->tokens, $i+1);
288
+                if ($token->isExplanationFunction()) {
289
+                    $leftover = array_slice($this->tokens, $i + 1);
290 290
                     $explanation = $this->parseExplanation($token, $leftover);
291 291
                 }
292 292
                 break;
293 293
             }
294 294
             
295
-            if($open && $subToken->isEncapsedString())
295
+            if ($open && $subToken->isEncapsedString())
296 296
             {
297 297
                 $textParts[] = $this->trimText($subToken->getValue());
298 298
                 continue;
299 299
             }
300 300
             
301
-            if($open && $subToken->isVariableOrFunction()) {
301
+            if ($open && $subToken->isVariableOrFunction()) {
302 302
                 $textParts = null;
303 303
                 $this->addWarning($subToken, t('Variables or functions are not supported in translation functions.'));
304 304
                 break;
305 305
             }
306 306
         }
307 307
         
308
-        if(empty($textParts)) {
308
+        if (empty($textParts)) {
309 309
             return;
310 310
         }
311 311
         
@@ -319,38 +319,38 @@  discard block
 block discarded – undo
319 319
         $textParts = array();
320 320
         $max = 200;
321 321
 
322
-        for($i = 0; $i < $max; $i++)
322
+        for ($i = 0; $i < $max; $i++)
323 323
         {
324
-            if(!isset($tokens[$i])) {
324
+            if (!isset($tokens[$i])) {
325 325
                 break;
326 326
             }
327 327
 
328 328
             $subToken = $this->createToken($tokens[$i], $token);
329 329
 
330
-            if($subToken->isClosingFuncParams()) {
330
+            if ($subToken->isClosingFuncParams()) {
331 331
                 break;
332 332
             }
333 333
 
334 334
             // additional parameters in the translation function, we don't want to capture these now.
335
-            if($subToken->isArgumentSeparator())
335
+            if ($subToken->isArgumentSeparator())
336 336
             {
337 337
                 break;
338 338
             }
339 339
 
340
-            if($subToken->isEncapsedString())
340
+            if ($subToken->isEncapsedString())
341 341
             {
342 342
                 $textParts[] = $this->trimText($subToken->getValue());
343 343
                 continue;
344 344
             }
345 345
 
346
-            if($subToken->isVariableOrFunction()) {
346
+            if ($subToken->isVariableOrFunction()) {
347 347
                 $textParts = null;
348 348
                 $this->addWarning($subToken, t('Variables or functions are not supported in translation functions.'));
349 349
                 break;
350 350
             }
351 351
         }
352 352
 
353
-        if(empty($textParts)) {
353
+        if (empty($textParts)) {
354 354
             return '';
355 355
         }
356 356
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
     protected function debug(string $text) : void
361 361
     {
362
-        if($this->debug) {
362
+        if ($this->debug) {
363 363
             echo $text;
364 364
         }
365 365
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -124,8 +124,7 @@
 block discarded – undo
124 124
         try
125 125
         {
126 126
             $this->content = FileHelper::readContents($path);
127
-        }
128
-        catch (FileHelper_Exception $e)
127
+        } catch (FileHelper_Exception $e)
129 128
         {
130 129
             throw new Localization_Exception(
131 130
                 sprintf('Source code file [%s] could not be read', basename($path)),
Please login to merge, or discard this patch.
src/Localization/Event/LocaleChanged.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
     const ERROR_NO_CURRENT_LOCALE_SPECIFIED = 91401;
26 26
 
27 27
     /**
28
-    * The locale that was used before the change, if any.
29
-    * @return Localization_Locale|NULL
30
-    */
28
+     * The locale that was used before the change, if any.
29
+     * @return Localization_Locale|NULL
30
+     */
31 31
     public function getPrevious() : ?Localization_Locale
32 32
     {
33 33
         $arg = $this->getArgument(1);
@@ -59,28 +59,28 @@  discard block
 block discarded – undo
59 59
         );
60 60
     }
61 61
     
62
-   /**
63
-    * The namespace in which the locale change occurred.
64
-    * @return string
65
-    */
62
+    /**
63
+     * The namespace in which the locale change occurred.
64
+     * @return string
65
+     */
66 66
     public function getNamespace() : string
67 67
     {
68 68
         return strval($this->getArgument(0));
69 69
     }
70 70
 
71
-   /**
72
-    * Whether the change occurred for an application locale.
73
-    * @return bool
74
-    */
71
+    /**
72
+     * Whether the change occurred for an application locale.
73
+     * @return bool
74
+     */
75 75
     public function isAppLocale() : bool
76 76
     {
77 77
         return $this->getNamespace() === Localization::NAMESPACE_APPLICATION;
78 78
     }
79 79
     
80
-   /**
81
-    * Whether the change occurred for a content locale.
82
-    * @return bool
83
-    */
80
+    /**
81
+     * Whether the change occurred for a content locale.
82
+     * @return bool
83
+     */
84 84
     public function isContentLocale() : bool
85 85
     {
86 86
         return $this->getNamespace() === Localization::NAMESPACE_CONTENT;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function getPrevious() : ?Localization_Locale
32 32
     {
33 33
         $arg = $this->getArgument(1);
34
-        if($arg instanceof Localization_Locale) {
34
+        if ($arg instanceof Localization_Locale) {
35 35
             return $arg;
36 36
         }
37 37
         
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $arg = $this->getArgument(2);
50 50
 
51
-        if($arg instanceof Localization_Locale) {
51
+        if ($arg instanceof Localization_Locale) {
52 52
             return $arg;
53 53
         }
54 54
 
Please login to merge, or discard this patch.