@@ -11,8 +11,7 @@ |
||
11 | 11 | /** |
12 | 12 | * Describes log levels. |
13 | 13 | */ |
14 | -class LogLevel |
|
15 | -{ |
|
14 | +class LogLevel { |
|
16 | 15 | const EMERGENCY = 'emergency'; |
17 | 16 | const ALERT = 'alert'; |
18 | 17 | const CRITICAL = 'critical'; |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Main class to convert the plural rules of a language from CLDR to gettext. |
9 | 9 | */ |
10 | -class Language |
|
11 | -{ |
|
10 | +class Language { |
|
12 | 11 | /** |
13 | 12 | * The language ID. |
14 | 13 | * |
@@ -72,8 +71,7 @@ discard block |
||
72 | 71 | * |
73 | 72 | * @throws \Exception throws an Exception if $fullId is not valid |
74 | 73 | */ |
75 | - private function __construct($info) |
|
76 | - { |
|
74 | + private function __construct($info) { |
|
77 | 75 | $this->id = $info['id']; |
78 | 76 | $this->name = $info['name']; |
79 | 77 | $this->supersededBy = isset($info['supersededBy']) ? $info['supersededBy'] : null; |
@@ -115,8 +113,7 @@ discard block |
||
115 | 113 | * |
116 | 114 | * @return \Gettext\Languages\Language[] |
117 | 115 | */ |
118 | - public static function getAll() |
|
119 | - { |
|
116 | + public static function getAll() { |
|
120 | 117 | $result = array(); |
121 | 118 | foreach (array_keys(CldrData::getLanguageNames()) as $cldrLanguageId) { |
122 | 119 | $result[] = new self(CldrData::getLanguageInfo($cldrLanguageId)); |
@@ -132,8 +129,7 @@ discard block |
||
132 | 129 | * |
133 | 130 | * @return \Gettext\Languages\Language|null |
134 | 131 | */ |
135 | - public static function getById($id) |
|
136 | - { |
|
132 | + public static function getById($id) { |
|
137 | 133 | $result = null; |
138 | 134 | $info = CldrData::getLanguageInfo($id); |
139 | 135 | if (isset($info)) { |
@@ -148,8 +144,7 @@ discard block |
||
148 | 144 | * |
149 | 145 | * @return \Gettext\Languages\Language |
150 | 146 | */ |
151 | - public function getUSAsciiClone() |
|
152 | - { |
|
147 | + public function getUSAsciiClone() { |
|
153 | 148 | $clone = clone $this; |
154 | 149 | self::asciifier($clone->name); |
155 | 150 | self::asciifier($clone->formula); |
@@ -170,8 +165,7 @@ discard block |
||
170 | 165 | * |
171 | 166 | * @return string |
172 | 167 | */ |
173 | - public function buildFormula($withoutParenthesis = false) |
|
174 | - { |
|
168 | + public function buildFormula($withoutParenthesis = false) { |
|
175 | 169 | $numCategories = count($this->categories); |
176 | 170 | switch ($numCategories) { |
177 | 171 | case 1: |
@@ -203,8 +197,7 @@ discard block |
||
203 | 197 | * |
204 | 198 | * @throws \Exception |
205 | 199 | */ |
206 | - private function checkAlwaysTrueCategories() |
|
207 | - { |
|
200 | + private function checkAlwaysTrueCategories() { |
|
208 | 201 | $alwaysTrueCategory = null; |
209 | 202 | foreach ($this->categories as $category) { |
210 | 203 | if ($category->formula === true) { |
@@ -234,8 +227,7 @@ discard block |
||
234 | 227 | * |
235 | 228 | * @throws \Exception |
236 | 229 | */ |
237 | - private function checkAlwaysFalseCategories() |
|
238 | - { |
|
230 | + private function checkAlwaysFalseCategories() { |
|
239 | 231 | $filtered = array(); |
240 | 232 | foreach ($this->categories as $category) { |
241 | 233 | if ($category->formula === false) { |
@@ -256,8 +248,7 @@ discard block |
||
256 | 248 | * |
257 | 249 | * @throws \Exception |
258 | 250 | */ |
259 | - private function checkAllCategoriesWithExamples() |
|
260 | - { |
|
251 | + private function checkAllCategoriesWithExamples() { |
|
261 | 252 | $allCategoriesIds = array(); |
262 | 253 | $goodCategories = array(); |
263 | 254 | $badCategories = array(); |
@@ -337,8 +328,7 @@ discard block |
||
337 | 328 | * |
338 | 329 | * @return string |
339 | 330 | */ |
340 | - private static function reverseFormula($formula) |
|
341 | - { |
|
331 | + private static function reverseFormula($formula) { |
|
342 | 332 | if (preg_match('/^n( % \d+)? == \d+(\.\.\d+|,\d+)*?$/', $formula)) { |
343 | 333 | return str_replace(' == ', ' != ', $formula); |
344 | 334 | } |
@@ -368,8 +358,7 @@ discard block |
||
368 | 358 | * |
369 | 359 | * @return string |
370 | 360 | */ |
371 | - private static function reduceFormula($formula) |
|
372 | - { |
|
361 | + private static function reduceFormula($formula) { |
|
373 | 362 | $map = array( |
374 | 363 | 'n != 0 && n != 1' => 'n > 1', |
375 | 364 | '(n == 0 || n == 1) && n != 0' => 'n == 1', |
@@ -385,8 +374,7 @@ discard block |
||
385 | 374 | * |
386 | 375 | * @throws \Exception |
387 | 376 | */ |
388 | - private static function asciifier(&$value) |
|
389 | - { |
|
377 | + private static function asciifier(&$value) { |
|
390 | 378 | if (is_string($value) && $value !== '') { |
391 | 379 | // Avoid converting from 'Ÿ' to '"Y', let's prefer 'Y' |
392 | 380 | $value = strtr($value, array( |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Holds the CLDR data. |
9 | 9 | */ |
10 | -class CldrData |
|
11 | -{ |
|
10 | +class CldrData { |
|
12 | 11 | /** |
13 | 12 | * Super-special plural category: this should always be present for any language. |
14 | 13 | * |
@@ -42,8 +41,7 @@ discard block |
||
42 | 41 | * |
43 | 42 | * @return string[] |
44 | 43 | */ |
45 | - public static function getLanguageNames() |
|
46 | - { |
|
44 | + public static function getLanguageNames() { |
|
47 | 45 | return self::getData('languages'); |
48 | 46 | } |
49 | 47 | |
@@ -54,8 +52,7 @@ discard block |
||
54 | 52 | * |
55 | 53 | * @return string[] |
56 | 54 | */ |
57 | - public static function getTerritoryNames() |
|
58 | - { |
|
55 | + public static function getTerritoryNames() { |
|
59 | 56 | return self::getData('territories'); |
60 | 57 | } |
61 | 58 | |
@@ -68,8 +65,7 @@ discard block |
||
68 | 65 | * |
69 | 66 | * @return string[] |
70 | 67 | */ |
71 | - public static function getScriptNames($standAlone) |
|
72 | - { |
|
68 | + public static function getScriptNames($standAlone) { |
|
73 | 69 | return self::getData($standAlone ? 'standAloneScripts' : 'scripts'); |
74 | 70 | } |
75 | 71 | |
@@ -88,8 +84,7 @@ discard block |
||
88 | 84 | * |
89 | 85 | * @return array |
90 | 86 | */ |
91 | - public static function getPlurals() |
|
92 | - { |
|
87 | + public static function getPlurals() { |
|
93 | 88 | return self::getData('plurals'); |
94 | 89 | } |
95 | 90 | |
@@ -98,8 +93,7 @@ discard block |
||
98 | 93 | * |
99 | 94 | * @return array keys are the former language codes, values are the new language/locale codes |
100 | 95 | */ |
101 | - public static function getSupersededLanguages() |
|
102 | - { |
|
96 | + public static function getSupersededLanguages() { |
|
103 | 97 | return self::getData('supersededLanguages'); |
104 | 98 | } |
105 | 99 | |
@@ -110,8 +104,7 @@ discard block |
||
110 | 104 | * |
111 | 105 | * @return array|null Returns an array with the keys 'id' (normalized), 'name', 'supersededBy' (optional), 'territory' (optional), 'script' (optional), 'baseLanguage' (optional), 'categories'. If $id is not valid returns null. |
112 | 106 | */ |
113 | - public static function getLanguageInfo($id) |
|
114 | - { |
|
107 | + public static function getLanguageInfo($id) { |
|
115 | 108 | $result = null; |
116 | 109 | $matches = array(); |
117 | 110 | if (preg_match('/^([a-z]{2,3})(?:[_\-]([a-z]{4}))?(?:[_\-]([a-z]{2}|[0-9]{3}))?(?:$|-)/i', $id, $matches)) { |
@@ -235,8 +228,7 @@ discard block |
||
235 | 228 | * |
236 | 229 | * @return array |
237 | 230 | */ |
238 | - private static function getData($key) |
|
239 | - { |
|
231 | + private static function getData($key) { |
|
240 | 232 | if (!isset(self::$data)) { |
241 | 233 | $fixKeys = function ($list, &$standAlone = null) { |
242 | 234 | $result = array(); |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Base class for all the exporters. |
9 | 9 | */ |
10 | -abstract class Exporter |
|
11 | -{ |
|
10 | +abstract class Exporter { |
|
12 | 11 | /** |
13 | 12 | * @var array |
14 | 13 | */ |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | * |
22 | 21 | * @return string[] |
23 | 22 | */ |
24 | - final public static function getExporters($onlyForPublicUse = false) |
|
25 | - { |
|
23 | + final public static function getExporters($onlyForPublicUse = false) { |
|
26 | 24 | if (!isset(self::$exporters)) { |
27 | 25 | $exporters = array(); |
28 | 26 | $m = null; |
@@ -58,8 +56,7 @@ discard block |
||
58 | 56 | * |
59 | 57 | * @return string |
60 | 58 | */ |
61 | - final public static function getExporterDescription($exporterHandle) |
|
62 | - { |
|
59 | + final public static function getExporterDescription($exporterHandle) { |
|
63 | 60 | $exporters = self::getExporters(); |
64 | 61 | if (!isset($exporters[$exporterHandle])) { |
65 | 62 | throw new Exception("Invalid exporter handle: '{$exporterHandle}'"); |
@@ -75,8 +72,7 @@ discard block |
||
75 | 72 | * |
76 | 73 | * @return string |
77 | 74 | */ |
78 | - final public static function getExporterClassName($exporterHandle) |
|
79 | - { |
|
75 | + final public static function getExporterClassName($exporterHandle) { |
|
80 | 76 | return __NAMESPACE__ . '\\' . ucfirst(strtolower($exporterHandle)); |
81 | 77 | } |
82 | 78 | |
@@ -88,8 +84,7 @@ discard block |
||
88 | 84 | * |
89 | 85 | * @return string |
90 | 86 | */ |
91 | - final public static function toString($languages, $options = null) |
|
92 | - { |
|
87 | + final public static function toString($languages, $options = null) { |
|
93 | 88 | if (isset($options) && is_array($options)) { |
94 | 89 | if (isset($options['us-ascii']) && $options['us-ascii']) { |
95 | 90 | $asciiList = array(); |
@@ -111,8 +106,7 @@ discard block |
||
111 | 106 | * |
112 | 107 | * @throws \Exception |
113 | 108 | */ |
114 | - final public static function toFile($languages, $filename, $options = null) |
|
115 | - { |
|
109 | + final public static function toFile($languages, $filename, $options = null) { |
|
116 | 110 | $data = self::toString($languages, $options); |
117 | 111 | if (@file_put_contents($filename, $data) === false) { |
118 | 112 | throw new Exception("Error writing data to '{$filename}'"); |
@@ -124,8 +118,7 @@ discard block |
||
124 | 118 | * |
125 | 119 | * @return bool |
126 | 120 | */ |
127 | - public static function isForPublicUse() |
|
128 | - { |
|
121 | + public static function isForPublicUse() { |
|
129 | 122 | return true; |
130 | 123 | } |
131 | 124 | |
@@ -134,8 +127,7 @@ discard block |
||
134 | 127 | * |
135 | 128 | * @return string |
136 | 129 | */ |
137 | - public static function getDescription() |
|
138 | - { |
|
130 | + public static function getDescription() { |
|
139 | 131 | throw new Exception(get_called_class() . ' does not implement the method ' . __FUNCTION__); |
140 | 132 | } |
141 | 133 | |
@@ -146,8 +138,7 @@ discard block |
||
146 | 138 | * |
147 | 139 | * @return string |
148 | 140 | */ |
149 | - protected static function toStringDo($languages) |
|
150 | - { |
|
141 | + protected static function toStringDo($languages) { |
|
151 | 142 | throw new Exception(get_called_class() . ' does not implement the method ' . __FUNCTION__); |
152 | 143 | } |
153 | 144 | } |
@@ -2,15 +2,13 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Gettext\Languages\Exporter; |
4 | 4 | |
5 | -class Html extends Exporter |
|
6 | -{ |
|
5 | +class Html extends Exporter { |
|
7 | 6 | /** |
8 | 7 | * {@inheritdoc} |
9 | 8 | * |
10 | 9 | * @see \Gettext\Languages\Exporter\Exporter::getDescription() |
11 | 10 | */ |
12 | - public static function getDescription() |
|
13 | - { |
|
11 | + public static function getDescription() { |
|
14 | 12 | return 'Build a HTML table'; |
15 | 13 | } |
16 | 14 | |
@@ -19,18 +17,15 @@ discard block |
||
19 | 17 | * |
20 | 18 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
21 | 19 | */ |
22 | - protected static function toStringDo($languages) |
|
23 | - { |
|
20 | + protected static function toStringDo($languages) { |
|
24 | 21 | return self::buildTable($languages, false); |
25 | 22 | } |
26 | 23 | |
27 | - protected static function h($str) |
|
28 | - { |
|
24 | + protected static function h($str) { |
|
29 | 25 | return htmlspecialchars($str, ENT_COMPAT, 'UTF-8'); |
30 | 26 | } |
31 | 27 | |
32 | - protected static function buildTable($languages, $forDocs) |
|
33 | - { |
|
28 | + protected static function buildTable($languages, $forDocs) { |
|
34 | 29 | $prefix = $forDocs ? ' ' : ''; |
35 | 30 | $lines = array(); |
36 | 31 | $lines[] = $prefix . '<table' . ($forDocs ? ' class="table table-bordered table-condensed table-striped"' : '') . '>'; |
@@ -2,15 +2,13 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Gettext\Languages\Exporter; |
4 | 4 | |
5 | -class Xml extends Exporter |
|
6 | -{ |
|
5 | +class Xml extends Exporter { |
|
7 | 6 | /** |
8 | 7 | * {@inheritdoc} |
9 | 8 | * |
10 | 9 | * @see \Gettext\Languages\Exporter\Exporter::getDescription() |
11 | 10 | */ |
12 | - public static function getDescription() |
|
13 | - { |
|
11 | + public static function getDescription() { |
|
14 | 12 | return 'Build an XML file - schema available at http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd'; |
15 | 13 | } |
16 | 14 | |
@@ -19,8 +17,7 @@ discard block |
||
19 | 17 | * |
20 | 18 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
21 | 19 | */ |
22 | - protected static function toStringDo($languages) |
|
23 | - { |
|
20 | + protected static function toStringDo($languages) { |
|
24 | 21 | $xml = new \DOMDocument('1.0', 'UTF-8'); |
25 | 22 | $xml->loadXML('<languages |
26 | 23 | xmlns="https://github.com/mlocati/cldr-to-gettext-plural-rules" |
@@ -2,15 +2,13 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Gettext\Languages\Exporter; |
4 | 4 | |
5 | -class Docs extends Html |
|
6 | -{ |
|
5 | +class Docs extends Html { |
|
7 | 6 | /** |
8 | 7 | * {@inheritdoc} |
9 | 8 | * |
10 | 9 | * @see \Gettext\Languages\Exporter\Exporter::isForPublicUse() |
11 | 10 | */ |
12 | - public static function isForPublicUse() |
|
13 | - { |
|
11 | + public static function isForPublicUse() { |
|
14 | 12 | return false; |
15 | 13 | } |
16 | 14 | |
@@ -19,8 +17,7 @@ discard block |
||
19 | 17 | * |
20 | 18 | * @see \Gettext\Languages\Exporter\Exporter::getDescription() |
21 | 19 | */ |
22 | - public static function getDescription() |
|
23 | - { |
|
20 | + public static function getDescription() { |
|
24 | 21 | return 'Build the page https://php-gettext.github.io/Languages/'; |
25 | 22 | } |
26 | 23 | |
@@ -29,8 +26,7 @@ discard block |
||
29 | 26 | * |
30 | 27 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
31 | 28 | */ |
32 | - protected static function toStringDo($languages) |
|
33 | - { |
|
29 | + protected static function toStringDo($languages) { |
|
34 | 30 | $result = <<<'EOT' |
35 | 31 | <!doctype html> |
36 | 32 | <html lang="en"> |
@@ -4,15 +4,13 @@ discard block |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -class Po extends Exporter |
|
8 | -{ |
|
7 | +class Po extends Exporter { |
|
9 | 8 | /** |
10 | 9 | * {@inheritdoc} |
11 | 10 | * |
12 | 11 | * @see \Gettext\Languages\Exporter\Exporter::getDescription() |
13 | 12 | */ |
14 | - public static function getDescription() |
|
15 | - { |
|
13 | + public static function getDescription() { |
|
16 | 14 | return 'Build a string to be used for gettext .po files'; |
17 | 15 | } |
18 | 16 | |
@@ -21,8 +19,7 @@ discard block |
||
21 | 19 | * |
22 | 20 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
23 | 21 | */ |
24 | - protected static function toStringDo($languages) |
|
25 | - { |
|
22 | + protected static function toStringDo($languages) { |
|
26 | 23 | if (count($languages) !== 1) { |
27 | 24 | throw new Exception('The ' . get_called_class() . ' exporter can only export one language'); |
28 | 25 | } |
@@ -2,15 +2,13 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Gettext\Languages\Exporter; |
4 | 4 | |
5 | -class Json extends Exporter |
|
6 | -{ |
|
5 | +class Json extends Exporter { |
|
7 | 6 | /** |
8 | 7 | * {@inheritdoc} |
9 | 8 | * |
10 | 9 | * @see \Gettext\Languages\Exporter\Exporter::getDescription() |
11 | 10 | */ |
12 | - public static function getDescription() |
|
13 | - { |
|
11 | + public static function getDescription() { |
|
14 | 12 | return 'Build a compressed JSON-encoded file'; |
15 | 13 | } |
16 | 14 | |
@@ -19,8 +17,7 @@ discard block |
||
19 | 17 | * |
20 | 18 | * @return int |
21 | 19 | */ |
22 | - protected static function getEncodeOptions() |
|
23 | - { |
|
20 | + protected static function getEncodeOptions() { |
|
24 | 21 | $result = 0; |
25 | 22 | if (defined('\JSON_UNESCAPED_SLASHES')) { |
26 | 23 | $result |= \JSON_UNESCAPED_SLASHES; |
@@ -37,8 +34,7 @@ discard block |
||
37 | 34 | * |
38 | 35 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
39 | 36 | */ |
40 | - protected static function toStringDo($languages) |
|
41 | - { |
|
37 | + protected static function toStringDo($languages) { |
|
42 | 38 | $list = array(); |
43 | 39 | foreach ($languages as $language) { |
44 | 40 | $item = array(); |