@@ -72,35 +72,35 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @throws \Exception throws an Exception if $fullId is not valid |
| 74 | 74 | */ |
| 75 | - private function __construct($info) |
|
| 75 | + private function __construct( $info ) |
|
| 76 | 76 | { |
| 77 | - $this->id = $info['id']; |
|
| 78 | - $this->name = $info['name']; |
|
| 79 | - $this->supersededBy = isset($info['supersededBy']) ? $info['supersededBy'] : null; |
|
| 80 | - $this->script = isset($info['script']) ? $info['script'] : null; |
|
| 81 | - $this->territory = isset($info['territory']) ? $info['territory'] : null; |
|
| 82 | - $this->baseLanguage = isset($info['baseLanguage']) ? $info['baseLanguage'] : null; |
|
| 77 | + $this->id = $info[ 'id' ]; |
|
| 78 | + $this->name = $info[ 'name' ]; |
|
| 79 | + $this->supersededBy = isset( $info[ 'supersededBy' ] ) ? $info[ 'supersededBy' ] : null; |
|
| 80 | + $this->script = isset( $info[ 'script' ] ) ? $info[ 'script' ] : null; |
|
| 81 | + $this->territory = isset( $info[ 'territory' ] ) ? $info[ 'territory' ] : null; |
|
| 82 | + $this->baseLanguage = isset( $info[ 'baseLanguage' ] ) ? $info[ 'baseLanguage' ] : null; |
|
| 83 | 83 | // Let's build the category list |
| 84 | 84 | $this->categories = array(); |
| 85 | - foreach ($info['categories'] as $cldrCategoryId => $cldrFormulaAndExamples) { |
|
| 86 | - $category = new Category($cldrCategoryId, $cldrFormulaAndExamples); |
|
| 87 | - foreach ($this->categories as $c) { |
|
| 88 | - if ($category->id === $c->id) { |
|
| 89 | - throw new Exception("The category '{$category->id}' is specified more than once"); |
|
| 85 | + foreach ( $info[ 'categories' ] as $cldrCategoryId => $cldrFormulaAndExamples ) { |
|
| 86 | + $category = new Category( $cldrCategoryId, $cldrFormulaAndExamples ); |
|
| 87 | + foreach ( $this->categories as $c ) { |
|
| 88 | + if ( $category->id === $c->id ) { |
|
| 89 | + throw new Exception( "The category '{$category->id}' is specified more than once" ); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | - $this->categories[] = $category; |
|
| 92 | + $this->categories[ ] = $category; |
|
| 93 | 93 | } |
| 94 | - if (empty($this->categories)) { |
|
| 95 | - throw new Exception("The language '{$info['id']}' does not have any plural category"); |
|
| 94 | + if ( empty( $this->categories ) ) { |
|
| 95 | + throw new Exception( "The language '{$info[ 'id' ]}' does not have any plural category" ); |
|
| 96 | 96 | } |
| 97 | 97 | // Let's sort the categories from 'zero' to 'other' |
| 98 | - usort($this->categories, function (Category $category1, Category $category2) { |
|
| 99 | - return array_search($category1->id, CldrData::$categories) - array_search($category2->id, CldrData::$categories); |
|
| 98 | + usort( $this->categories, function( Category $category1, Category $category2 ) { |
|
| 99 | + return array_search( $category1->id, CldrData::$categories ) - array_search( $category2->id, CldrData::$categories ); |
|
| 100 | 100 | }); |
| 101 | 101 | // The 'other' category should always be there |
| 102 | - if ($this->categories[count($this->categories) - 1]->id !== CldrData::OTHER_CATEGORY) { |
|
| 103 | - throw new Exception("The language '{$info['id']}' does not have the '" . CldrData::OTHER_CATEGORY . "' plural category"); |
|
| 102 | + if ( $this->categories[ count( $this->categories ) - 1 ]->id !== CldrData::OTHER_CATEGORY ) { |
|
| 103 | + throw new Exception( "The language '{$info[ 'id' ]}' does not have the '" . CldrData::OTHER_CATEGORY . "' plural category" ); |
|
| 104 | 104 | } |
| 105 | 105 | $this->checkAlwaysTrueCategories(); |
| 106 | 106 | $this->checkAlwaysFalseCategories(); |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | public static function getAll() |
| 119 | 119 | { |
| 120 | 120 | $result = array(); |
| 121 | - foreach (array_keys(CldrData::getLanguageNames()) as $cldrLanguageId) { |
|
| 122 | - $result[] = new self(CldrData::getLanguageInfo($cldrLanguageId)); |
|
| 121 | + foreach ( array_keys( CldrData::getLanguageNames() ) as $cldrLanguageId ) { |
|
| 122 | + $result[ ] = new self( CldrData::getLanguageInfo( $cldrLanguageId ) ); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $result; |
@@ -132,12 +132,12 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return \Gettext\Languages\Language|null |
| 134 | 134 | */ |
| 135 | - public static function getById($id) |
|
| 135 | + public static function getById( $id ) |
|
| 136 | 136 | { |
| 137 | 137 | $result = null; |
| 138 | - $info = CldrData::getLanguageInfo($id); |
|
| 139 | - if (isset($info)) { |
|
| 140 | - $result = new self($info); |
|
| 138 | + $info = CldrData::getLanguageInfo( $id ); |
|
| 139 | + if ( isset( $info ) ) { |
|
| 140 | + $result = new self( $info ); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $result; |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | public function getUSAsciiClone() |
| 152 | 152 | { |
| 153 | 153 | $clone = clone $this; |
| 154 | - self::asciifier($clone->name); |
|
| 155 | - self::asciifier($clone->formula); |
|
| 154 | + self::asciifier( $clone->name ); |
|
| 155 | + self::asciifier( $clone->formula ); |
|
| 156 | 156 | $clone->categories = array(); |
| 157 | - foreach ($this->categories as $category) { |
|
| 157 | + foreach ( $this->categories as $category ) { |
|
| 158 | 158 | $categoryClone = clone $category; |
| 159 | - self::asciifier($categoryClone->examples); |
|
| 160 | - $clone->categories[] = $categoryClone; |
|
| 159 | + self::asciifier( $categoryClone->examples ); |
|
| 160 | + $clone->categories[ ] = $categoryClone; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | return $clone; |
@@ -170,24 +170,24 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @return string |
| 172 | 172 | */ |
| 173 | - public function buildFormula($withoutParenthesis = false) |
|
| 173 | + public function buildFormula( $withoutParenthesis = false ) |
|
| 174 | 174 | { |
| 175 | - $numCategories = count($this->categories); |
|
| 176 | - switch ($numCategories) { |
|
| 175 | + $numCategories = count( $this->categories ); |
|
| 176 | + switch ( $numCategories ) { |
|
| 177 | 177 | case 1: |
| 178 | 178 | // Just one category |
| 179 | 179 | return '0'; |
| 180 | 180 | case 2: |
| 181 | - return self::reduceFormula(self::reverseFormula($this->categories[0]->formula)); |
|
| 181 | + return self::reduceFormula( self::reverseFormula( $this->categories[ 0 ]->formula ) ); |
|
| 182 | 182 | default: |
| 183 | - $formula = (string) ($numCategories - 1); |
|
| 184 | - for ($i = $numCategories - 2; $i >= 0; $i--) { |
|
| 185 | - $f = self::reduceFormula($this->categories[$i]->formula); |
|
| 186 | - if (!$withoutParenthesis && !preg_match('/^\([^()]+\)$/', $f)) { |
|
| 183 | + $formula = (string)( $numCategories - 1 ); |
|
| 184 | + for ( $i = $numCategories - 2; $i >= 0; $i-- ) { |
|
| 185 | + $f = self::reduceFormula( $this->categories[ $i ]->formula ); |
|
| 186 | + if ( ! $withoutParenthesis && ! preg_match( '/^\([^()]+\)$/', $f ) ) { |
|
| 187 | 187 | $f = "({$f})"; |
| 188 | 188 | } |
| 189 | 189 | $formula = "{$f} ? {$i} : {$formula}"; |
| 190 | - if (!$withoutParenthesis && $i > 0) { |
|
| 190 | + if ( ! $withoutParenthesis && $i > 0 ) { |
|
| 191 | 191 | $formula = "({$formula})"; |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -206,24 +206,24 @@ discard block |
||
| 206 | 206 | private function checkAlwaysTrueCategories() |
| 207 | 207 | { |
| 208 | 208 | $alwaysTrueCategory = null; |
| 209 | - foreach ($this->categories as $category) { |
|
| 210 | - if ($category->formula === true) { |
|
| 211 | - if (!isset($category->examples)) { |
|
| 212 | - throw new Exception("The category '{$category->id}' should always occur, but it does not have examples (so for CLDR it will never occur for integers!)"); |
|
| 209 | + foreach ( $this->categories as $category ) { |
|
| 210 | + if ( $category->formula === true ) { |
|
| 211 | + if ( ! isset( $category->examples ) ) { |
|
| 212 | + throw new Exception( "The category '{$category->id}' should always occur, but it does not have examples (so for CLDR it will never occur for integers!)" ); |
|
| 213 | 213 | } |
| 214 | 214 | $alwaysTrueCategory = $category; |
| 215 | 215 | break; |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | - if (isset($alwaysTrueCategory)) { |
|
| 219 | - foreach ($this->categories as $category) { |
|
| 220 | - if (($category !== $alwaysTrueCategory) && isset($category->examples)) { |
|
| 221 | - throw new Exception("The category '{$category->id}' should never occur, but it has some examples (so for CLDR it will occur!)"); |
|
| 218 | + if ( isset( $alwaysTrueCategory ) ) { |
|
| 219 | + foreach ( $this->categories as $category ) { |
|
| 220 | + if ( ( $category !== $alwaysTrueCategory ) && isset( $category->examples ) ) { |
|
| 221 | + throw new Exception( "The category '{$category->id}' should never occur, but it has some examples (so for CLDR it will occur!)" ); |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | $alwaysTrueCategory->id = CldrData::OTHER_CATEGORY; |
| 225 | 225 | $alwaysTrueCategory->formula = null; |
| 226 | - $this->categories = array($alwaysTrueCategory); |
|
| 226 | + $this->categories = array( $alwaysTrueCategory ); |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
@@ -237,13 +237,13 @@ discard block |
||
| 237 | 237 | private function checkAlwaysFalseCategories() |
| 238 | 238 | { |
| 239 | 239 | $filtered = array(); |
| 240 | - foreach ($this->categories as $category) { |
|
| 241 | - if ($category->formula === false) { |
|
| 242 | - if (isset($category->examples)) { |
|
| 243 | - throw new Exception("The category '{$category->id}' should never occur, but it has examples (so for CLDR it may occur!)"); |
|
| 240 | + foreach ( $this->categories as $category ) { |
|
| 241 | + if ( $category->formula === false ) { |
|
| 242 | + if ( isset( $category->examples ) ) { |
|
| 243 | + throw new Exception( "The category '{$category->id}' should never occur, but it has examples (so for CLDR it may occur!)" ); |
|
| 244 | 244 | } |
| 245 | 245 | } else { |
| 246 | - $filtered[] = $category; |
|
| 246 | + $filtered[ ] = $category; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | $this->categories = $filtered; |
@@ -262,22 +262,22 @@ discard block |
||
| 262 | 262 | $goodCategories = array(); |
| 263 | 263 | $badCategories = array(); |
| 264 | 264 | $badCategoriesIds = array(); |
| 265 | - foreach ($this->categories as $category) { |
|
| 266 | - $allCategoriesIds[] = $category->id; |
|
| 267 | - if (isset($category->examples)) { |
|
| 268 | - $goodCategories[] = $category; |
|
| 265 | + foreach ( $this->categories as $category ) { |
|
| 266 | + $allCategoriesIds[ ] = $category->id; |
|
| 267 | + if ( isset( $category->examples ) ) { |
|
| 268 | + $goodCategories[ ] = $category; |
|
| 269 | 269 | } else { |
| 270 | - $badCategories[] = $category; |
|
| 271 | - $badCategoriesIds[] = $category->id; |
|
| 270 | + $badCategories[ ] = $category; |
|
| 271 | + $badCategoriesIds[ ] = $category->id; |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | - if (empty($badCategories)) { |
|
| 274 | + if ( empty( $badCategories ) ) { |
|
| 275 | 275 | return; |
| 276 | 276 | } |
| 277 | 277 | $removeCategoriesWithoutExamples = false; |
| 278 | - switch (implode(',', $badCategoriesIds) . '@' . implode(',', $allCategoriesIds)) { |
|
| 278 | + switch ( implode( ',', $badCategoriesIds ) . '@' . implode( ',', $allCategoriesIds ) ) { |
|
| 279 | 279 | case CldrData::OTHER_CATEGORY . '@one,few,many,' . CldrData::OTHER_CATEGORY: |
| 280 | - switch ($this->buildFormula()) { |
|
| 280 | + switch ( $this->buildFormula() ) { |
|
| 281 | 281 | case '(n % 10 == 1 && n % 100 != 11) ? 0 : ((n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14)) ? 1 : ((n % 10 == 0 || n % 10 >= 5 && n % 10 <= 9 || n % 100 >= 11 && n % 100 <= 14) ? 2 : 3))': |
| 282 | 282 | // Numbers ending with 0 => case 2 ('many') |
| 283 | 283 | // Numbers ending with 1 but not with 11 => case 0 ('one') |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | break; |
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | - if (!$removeCategoriesWithoutExamples) { |
|
| 320 | - throw new Exception("Unhandled case of plural categories without examples '" . implode(', ', $badCategoriesIds) . "' out of '" . implode(', ', $allCategoriesIds) . "'"); |
|
| 319 | + if ( ! $removeCategoriesWithoutExamples ) { |
|
| 320 | + throw new Exception( "Unhandled case of plural categories without examples '" . implode( ', ', $badCategoriesIds ) . "' out of '" . implode( ', ', $allCategoriesIds ) . "'" ); |
|
| 321 | 321 | } |
| 322 | - if ($badCategories[count($badCategories) - 1]->id === CldrData::OTHER_CATEGORY) { |
|
| 322 | + if ( $badCategories[ count( $badCategories ) - 1 ]->id === CldrData::OTHER_CATEGORY ) { |
|
| 323 | 323 | // We're removing the 'other' cagory: let's change the last good category to 'other' |
| 324 | - $lastGood = $goodCategories[count($goodCategories) - 1]; |
|
| 324 | + $lastGood = $goodCategories[ count( $goodCategories ) - 1 ]; |
|
| 325 | 325 | $lastGood->id = CldrData::OTHER_CATEGORY; |
| 326 | 326 | $lastGood->formula = null; |
| 327 | 327 | } |
@@ -337,28 +337,28 @@ discard block |
||
| 337 | 337 | * |
| 338 | 338 | * @return string |
| 339 | 339 | */ |
| 340 | - private static function reverseFormula($formula) |
|
| 340 | + private static function reverseFormula( $formula ) |
|
| 341 | 341 | { |
| 342 | - if (preg_match('/^n( % \d+)? == \d+(\.\.\d+|,\d+)*?$/', $formula)) { |
|
| 343 | - return str_replace(' == ', ' != ', $formula); |
|
| 342 | + if ( preg_match( '/^n( % \d+)? == \d+(\.\.\d+|,\d+)*?$/', $formula ) ) { |
|
| 343 | + return str_replace( ' == ', ' != ', $formula ); |
|
| 344 | 344 | } |
| 345 | - if (preg_match('/^n( % \d+)? != \d+(\.\.\d+|,\d+)*?$/', $formula)) { |
|
| 346 | - return str_replace(' != ', ' == ', $formula); |
|
| 345 | + if ( preg_match( '/^n( % \d+)? != \d+(\.\.\d+|,\d+)*?$/', $formula ) ) { |
|
| 346 | + return str_replace( ' != ', ' == ', $formula ); |
|
| 347 | 347 | } |
| 348 | - if (preg_match('/^\(?n == \d+ \|\| n == \d+\)?$/', $formula)) { |
|
| 349 | - return trim(str_replace(array(' == ', ' || '), array(' != ', ' && '), $formula), '()'); |
|
| 348 | + if ( preg_match( '/^\(?n == \d+ \|\| n == \d+\)?$/', $formula ) ) { |
|
| 349 | + return trim( str_replace( array( ' == ', ' || ' ), array( ' != ', ' && ' ), $formula ), '()' ); |
|
| 350 | 350 | } |
| 351 | 351 | $m = null; |
| 352 | - if (preg_match('/^(n(?: % \d+)?) == (\d+) && (n(?: % \d+)?) != (\d+)$/', $formula, $m)) { |
|
| 353 | - return "{$m[1]} != {$m[2]} || {$m[3]} == {$m[4]}"; |
|
| 352 | + if ( preg_match( '/^(n(?: % \d+)?) == (\d+) && (n(?: % \d+)?) != (\d+)$/', $formula, $m ) ) { |
|
| 353 | + return "{$m[ 1 ]} != {$m[ 2 ]} || {$m[ 3 ]} == {$m[ 4 ]}"; |
|
| 354 | 354 | } |
| 355 | - switch ($formula) { |
|
| 355 | + switch ( $formula ) { |
|
| 356 | 356 | case '(n == 1 || n == 2 || n == 3) || n % 10 != 4 && n % 10 != 6 && n % 10 != 9': |
| 357 | 357 | return 'n != 1 && n != 2 && n != 3 && (n % 10 == 4 || n % 10 == 6 || n % 10 == 9)'; |
| 358 | 358 | case '(n == 0 || n == 1) || n >= 11 && n <= 99': |
| 359 | 359 | return 'n >= 2 && (n < 11 || n > 99)'; |
| 360 | 360 | } |
| 361 | - throw new Exception("Unable to reverse the formula '{$formula}'"); |
|
| 361 | + throw new Exception( "Unable to reverse the formula '{$formula}'" ); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -368,14 +368,14 @@ discard block |
||
| 368 | 368 | * |
| 369 | 369 | * @return string |
| 370 | 370 | */ |
| 371 | - private static function reduceFormula($formula) |
|
| 371 | + private static function reduceFormula( $formula ) |
|
| 372 | 372 | { |
| 373 | 373 | $map = array( |
| 374 | 374 | 'n != 0 && n != 1' => 'n > 1', |
| 375 | 375 | '(n == 0 || n == 1) && n != 0' => 'n == 1', |
| 376 | 376 | ); |
| 377 | 377 | |
| 378 | - return isset($map[$formula]) ? $map[$formula] : $formula; |
|
| 378 | + return isset( $map[ $formula ] ) ? $map[ $formula ] : $formula; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -385,11 +385,11 @@ discard block |
||
| 385 | 385 | * |
| 386 | 386 | * @throws \Exception |
| 387 | 387 | */ |
| 388 | - private static function asciifier(&$value) |
|
| 388 | + private static function asciifier( &$value ) |
|
| 389 | 389 | { |
| 390 | - if (is_string($value) && $value !== '') { |
|
| 390 | + if ( is_string( $value ) && $value !== '' ) { |
|
| 391 | 391 | // Avoid converting from 'Ÿ' to '"Y', let's prefer 'Y' |
| 392 | - $value = strtr($value, array( |
|
| 392 | + $value = strtr( $value, array( |
|
| 393 | 393 | 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', |
| 394 | 394 | 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', |
| 395 | 395 | 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | 'ý' => 'y', 'ÿ' => 'y', |
| 406 | 406 | '…' => '...', |
| 407 | 407 | 'ʼ' => "'", '’' => "'", |
| 408 | - )); |
|
| 408 | + ) ); |
|
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @var string[] |
| 23 | 23 | */ |
| 24 | - public static $categories = array('zero', 'one', 'two', 'few', 'many', self::OTHER_CATEGORY); |
|
| 24 | + public static $categories = array( 'zero', 'one', 'two', 'few', 'many', self::OTHER_CATEGORY ); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * The loaded CLDR data. |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public static function getLanguageNames() |
| 46 | 46 | { |
| 47 | - return self::getData('languages'); |
|
| 47 | + return self::getData( 'languages' ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public static function getTerritoryNames() |
| 58 | 58 | { |
| 59 | - return self::getData('territories'); |
|
| 59 | + return self::getData( 'territories' ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return string[] |
| 70 | 70 | */ |
| 71 | - public static function getScriptNames($standAlone) |
|
| 71 | + public static function getScriptNames( $standAlone ) |
|
| 72 | 72 | { |
| 73 | - return self::getData($standAlone ? 'standAloneScripts' : 'scripts'); |
|
| 73 | + return self::getData( $standAlone ? 'standAloneScripts' : 'scripts' ); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public static function getPlurals() |
| 92 | 92 | { |
| 93 | - return self::getData('plurals'); |
|
| 93 | + return self::getData( 'plurals' ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public static function getSupersededLanguages() |
| 102 | 102 | { |
| 103 | - return self::getData('supersededLanguages'); |
|
| 103 | + return self::getData( 'supersededLanguages' ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -110,54 +110,54 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @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 | 112 | */ |
| 113 | - public static function getLanguageInfo($id) |
|
| 113 | + public static function getLanguageInfo( $id ) |
|
| 114 | 114 | { |
| 115 | 115 | $result = null; |
| 116 | 116 | $matches = array(); |
| 117 | - if (preg_match('/^([a-z]{2,3})(?:[_\-]([a-z]{4}))?(?:[_\-]([a-z]{2}|[0-9]{3}))?(?:$|-)/i', $id, $matches)) { |
|
| 118 | - $languageId = strtolower($matches[1]); |
|
| 119 | - $scriptId = (isset($matches[2]) && ($matches[2] !== '')) ? ucfirst(strtolower($matches[2])) : null; |
|
| 120 | - $territoryId = (isset($matches[3]) && ($matches[3] !== '')) ? strtoupper($matches[3]) : null; |
|
| 117 | + if ( preg_match( '/^([a-z]{2,3})(?:[_\-]([a-z]{4}))?(?:[_\-]([a-z]{2}|[0-9]{3}))?(?:$|-)/i', $id, $matches ) ) { |
|
| 118 | + $languageId = strtolower( $matches[ 1 ] ); |
|
| 119 | + $scriptId = ( isset( $matches[ 2 ] ) && ( $matches[ 2 ] !== '' ) ) ? ucfirst( strtolower( $matches[ 2 ] ) ) : null; |
|
| 120 | + $territoryId = ( isset( $matches[ 3 ] ) && ( $matches[ 3 ] !== '' ) ) ? strtoupper( $matches[ 3 ] ) : null; |
|
| 121 | 121 | $normalizedId = $languageId; |
| 122 | - if (isset($scriptId)) { |
|
| 122 | + if ( isset( $scriptId ) ) { |
|
| 123 | 123 | $normalizedId .= '_' . $scriptId; |
| 124 | 124 | } |
| 125 | - if (isset($territoryId)) { |
|
| 125 | + if ( isset( $territoryId ) ) { |
|
| 126 | 126 | $normalizedId .= '_' . $territoryId; |
| 127 | 127 | } |
| 128 | 128 | // Structure precedence: see Likely Subtags - http://www.unicode.org/reports/tr35/tr35-31/tr35.html#Likely_Subtags |
| 129 | 129 | $variants = array(); |
| 130 | 130 | $variantsWithScript = array(); |
| 131 | 131 | $variantsWithTerritory = array(); |
| 132 | - if (isset($scriptId) && isset($territoryId)) { |
|
| 133 | - $variantsWithTerritory[] = $variantsWithScript[] = $variants[] = "{$languageId}_{$scriptId}_{$territoryId}"; |
|
| 132 | + if ( isset( $scriptId ) && isset( $territoryId ) ) { |
|
| 133 | + $variantsWithTerritory[ ] = $variantsWithScript[ ] = $variants[ ] = "{$languageId}_{$scriptId}_{$territoryId}"; |
|
| 134 | 134 | } |
| 135 | - if (isset($scriptId)) { |
|
| 136 | - $variantsWithScript[] = $variants[] = "{$languageId}_{$scriptId}"; |
|
| 135 | + if ( isset( $scriptId ) ) { |
|
| 136 | + $variantsWithScript[ ] = $variants[ ] = "{$languageId}_{$scriptId}"; |
|
| 137 | 137 | } |
| 138 | - if (isset($territoryId)) { |
|
| 139 | - $variantsWithTerritory[] = $variants[] = "{$languageId}_{$territoryId}"; |
|
| 138 | + if ( isset( $territoryId ) ) { |
|
| 139 | + $variantsWithTerritory[ ] = $variants[ ] = "{$languageId}_{$territoryId}"; |
|
| 140 | 140 | } |
| 141 | - $variants[] = $languageId; |
|
| 141 | + $variants[ ] = $languageId; |
|
| 142 | 142 | $allGood = true; |
| 143 | 143 | $scriptName = null; |
| 144 | 144 | $scriptStandAloneName = null; |
| 145 | - if (isset($scriptId)) { |
|
| 146 | - $scriptNames = self::getScriptNames(false); |
|
| 147 | - if (isset($scriptNames[$scriptId])) { |
|
| 148 | - $scriptName = $scriptNames[$scriptId]; |
|
| 149 | - $scriptStandAloneNames = self::getScriptNames(true); |
|
| 150 | - $scriptStandAloneName = $scriptStandAloneNames[$scriptId]; |
|
| 145 | + if ( isset( $scriptId ) ) { |
|
| 146 | + $scriptNames = self::getScriptNames( false ); |
|
| 147 | + if ( isset( $scriptNames[ $scriptId ] ) ) { |
|
| 148 | + $scriptName = $scriptNames[ $scriptId ]; |
|
| 149 | + $scriptStandAloneNames = self::getScriptNames( true ); |
|
| 150 | + $scriptStandAloneName = $scriptStandAloneNames[ $scriptId ]; |
|
| 151 | 151 | } else { |
| 152 | 152 | $allGood = false; |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | $territoryName = null; |
| 156 | - if (isset($territoryId)) { |
|
| 156 | + if ( isset( $territoryId ) ) { |
|
| 157 | 157 | $territoryNames = self::getTerritoryNames(); |
| 158 | - if (isset($territoryNames[$territoryId])) { |
|
| 159 | - if ($territoryId !== '001') { |
|
| 160 | - $territoryName = $territoryNames[$territoryId]; |
|
| 158 | + if ( isset( $territoryNames[ $territoryId ] ) ) { |
|
| 159 | + if ( $territoryId !== '001' ) { |
|
| 160 | + $territoryName = $territoryNames[ $territoryId ]; |
|
| 161 | 161 | } |
| 162 | 162 | } else { |
| 163 | 163 | $allGood = false; |
@@ -165,63 +165,63 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | $languageName = null; |
| 167 | 167 | $languageNames = self::getLanguageNames(); |
| 168 | - foreach ($variants as $variant) { |
|
| 169 | - if (isset($languageNames[$variant])) { |
|
| 170 | - $languageName = $languageNames[$variant]; |
|
| 171 | - if (isset($scriptName) && (!in_array($variant, $variantsWithScript))) { |
|
| 168 | + foreach ( $variants as $variant ) { |
|
| 169 | + if ( isset( $languageNames[ $variant ] ) ) { |
|
| 170 | + $languageName = $languageNames[ $variant ]; |
|
| 171 | + if ( isset( $scriptName ) && ( ! in_array( $variant, $variantsWithScript ) ) ) { |
|
| 172 | 172 | $languageName = $scriptName . ' ' . $languageName; |
| 173 | 173 | } |
| 174 | - if (isset($territoryName) && (!in_array($variant, $variantsWithTerritory))) { |
|
| 175 | - $languageName .= ' (' . $territoryNames[$territoryId] . ')'; |
|
| 174 | + if ( isset( $territoryName ) && ( ! in_array( $variant, $variantsWithTerritory ) ) ) { |
|
| 175 | + $languageName .= ' (' . $territoryNames[ $territoryId ] . ')'; |
|
| 176 | 176 | } |
| 177 | 177 | break; |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | - if (!isset($languageName)) { |
|
| 180 | + if ( ! isset( $languageName ) ) { |
|
| 181 | 181 | $allGood = false; |
| 182 | 182 | } |
| 183 | 183 | $baseLanguage = null; |
| 184 | - if (isset($scriptId) || isset($territoryId)) { |
|
| 185 | - if (isset($languageNames[$languageId]) && ($languageNames[$languageId] !== $languageName)) { |
|
| 186 | - $baseLanguage = $languageNames[$languageId]; |
|
| 184 | + if ( isset( $scriptId ) || isset( $territoryId ) ) { |
|
| 185 | + if ( isset( $languageNames[ $languageId ] ) && ( $languageNames[ $languageId ] !== $languageName ) ) { |
|
| 186 | + $baseLanguage = $languageNames[ $languageId ]; |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | $plural = null; |
| 190 | 190 | $plurals = self::getPlurals(); |
| 191 | - foreach ($variants as $variant) { |
|
| 192 | - if (isset($plurals[$variant])) { |
|
| 193 | - $plural = $plurals[$variant]; |
|
| 191 | + foreach ( $variants as $variant ) { |
|
| 192 | + if ( isset( $plurals[ $variant ] ) ) { |
|
| 193 | + $plural = $plurals[ $variant ]; |
|
| 194 | 194 | break; |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - if (!isset($plural)) { |
|
| 197 | + if ( ! isset( $plural ) ) { |
|
| 198 | 198 | $allGood = false; |
| 199 | 199 | } |
| 200 | 200 | $supersededBy = null; |
| 201 | 201 | $supersededBys = self::getSupersededLanguages(); |
| 202 | - foreach ($variants as $variant) { |
|
| 203 | - if (isset($supersededBys[$variant])) { |
|
| 204 | - $supersededBy = $supersededBys[$variant]; |
|
| 202 | + foreach ( $variants as $variant ) { |
|
| 203 | + if ( isset( $supersededBys[ $variant ] ) ) { |
|
| 204 | + $supersededBy = $supersededBys[ $variant ]; |
|
| 205 | 205 | break; |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | - if ($allGood) { |
|
| 208 | + if ( $allGood ) { |
|
| 209 | 209 | $result = array(); |
| 210 | - $result['id'] = $normalizedId; |
|
| 211 | - $result['name'] = $languageName; |
|
| 212 | - if (isset($supersededBy)) { |
|
| 213 | - $result['supersededBy'] = $supersededBy; |
|
| 210 | + $result[ 'id' ] = $normalizedId; |
|
| 211 | + $result[ 'name' ] = $languageName; |
|
| 212 | + if ( isset( $supersededBy ) ) { |
|
| 213 | + $result[ 'supersededBy' ] = $supersededBy; |
|
| 214 | 214 | } |
| 215 | - if (isset($scriptStandAloneName)) { |
|
| 216 | - $result['script'] = $scriptStandAloneName; |
|
| 215 | + if ( isset( $scriptStandAloneName ) ) { |
|
| 216 | + $result[ 'script' ] = $scriptStandAloneName; |
|
| 217 | 217 | } |
| 218 | - if (isset($territoryName)) { |
|
| 219 | - $result['territory'] = $territoryName; |
|
| 218 | + if ( isset( $territoryName ) ) { |
|
| 219 | + $result[ 'territory' ] = $territoryName; |
|
| 220 | 220 | } |
| 221 | - if (isset($baseLanguage)) { |
|
| 222 | - $result['baseLanguage'] = $baseLanguage; |
|
| 221 | + if ( isset( $baseLanguage ) ) { |
|
| 222 | + $result[ 'baseLanguage' ] = $baseLanguage; |
|
| 223 | 223 | } |
| 224 | - $result['categories'] = $plural; |
|
| 224 | + $result[ 'categories' ] = $plural; |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -235,21 +235,21 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return array |
| 237 | 237 | */ |
| 238 | - private static function getData($key) |
|
| 238 | + private static function getData( $key ) |
|
| 239 | 239 | { |
| 240 | - if (!isset(self::$data)) { |
|
| 241 | - $fixKeys = function ($list, &$standAlone = null) { |
|
| 240 | + if ( ! isset( self::$data ) ) { |
|
| 241 | + $fixKeys = function( $list, &$standAlone = null ) { |
|
| 242 | 242 | $result = array(); |
| 243 | 243 | $standAlone = array(); |
| 244 | 244 | $match = null; |
| 245 | - foreach ($list as $key => $value) { |
|
| 245 | + foreach ( $list as $key => $value ) { |
|
| 246 | 246 | $variant = ''; |
| 247 | - if (preg_match('/^(.+)-alt-(short|variant|stand-alone|long|menu)$/', $key, $match)) { |
|
| 248 | - $key = $match[1]; |
|
| 249 | - $variant = $match[2]; |
|
| 247 | + if ( preg_match( '/^(.+)-alt-(short|variant|stand-alone|long|menu)$/', $key, $match ) ) { |
|
| 248 | + $key = $match[ 1 ]; |
|
| 249 | + $variant = $match[ 2 ]; |
|
| 250 | 250 | } |
| 251 | - $key = str_replace('-', '_', $key); |
|
| 252 | - switch ($key) { |
|
| 251 | + $key = str_replace( '-', '_', $key ); |
|
| 252 | + switch ( $key ) { |
|
| 253 | 253 | case 'root': // Language: Root |
| 254 | 254 | case 'und': // Language: Unknown Language |
| 255 | 255 | case 'zxx': // Language: No linguistic content |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | case 'Zzzz': // Script: Unknown Script |
| 263 | 263 | break; |
| 264 | 264 | default: |
| 265 | - switch ($variant) { |
|
| 265 | + switch ( $variant ) { |
|
| 266 | 266 | case 'stand-alone': |
| 267 | - $standAlone[$key] = $value; |
|
| 267 | + $standAlone[ $key ] = $value; |
|
| 268 | 268 | break; |
| 269 | 269 | case '': |
| 270 | - $result[$key] = $value; |
|
| 270 | + $result[ $key ] = $value; |
|
| 271 | 271 | break; |
| 272 | 272 | } |
| 273 | 273 | break; |
@@ -277,26 +277,26 @@ discard block |
||
| 277 | 277 | return $result; |
| 278 | 278 | }; |
| 279 | 279 | $data = array(); |
| 280 | - $json = json_decode(file_get_contents(__DIR__ . '/cldr-data/main/en-US/languages.json'), true); |
|
| 281 | - $data['languages'] = $fixKeys($json['main']['en-US']['localeDisplayNames']['languages']); |
|
| 282 | - $json = json_decode(file_get_contents(__DIR__ . '/cldr-data/main/en-US/territories.json'), true); |
|
| 283 | - $data['territories'] = $fixKeys($json['main']['en-US']['localeDisplayNames']['territories']); |
|
| 284 | - $json = json_decode(file_get_contents(__DIR__ . '/cldr-data/supplemental/plurals.json'), true); |
|
| 285 | - $data['plurals'] = $fixKeys($json['supplemental']['plurals-type-cardinal']); |
|
| 286 | - $json = json_decode(file_get_contents(__DIR__ . '/cldr-data/main/en-US/scripts.json'), true); |
|
| 287 | - $data['scripts'] = $fixKeys($json['main']['en-US']['localeDisplayNames']['scripts'], $data['standAloneScripts']); |
|
| 288 | - $data['standAloneScripts'] = array_merge($data['scripts'], $data['standAloneScripts']); |
|
| 289 | - $data['scripts'] = array_merge($data['standAloneScripts'], $data['scripts']); |
|
| 290 | - $data['supersededLanguages'] = array(); |
|
| 280 | + $json = json_decode( file_get_contents( __DIR__ . '/cldr-data/main/en-US/languages.json' ), true ); |
|
| 281 | + $data[ 'languages' ] = $fixKeys( $json[ 'main' ][ 'en-US' ][ 'localeDisplayNames' ][ 'languages' ] ); |
|
| 282 | + $json = json_decode( file_get_contents( __DIR__ . '/cldr-data/main/en-US/territories.json' ), true ); |
|
| 283 | + $data[ 'territories' ] = $fixKeys( $json[ 'main' ][ 'en-US' ][ 'localeDisplayNames' ][ 'territories' ] ); |
|
| 284 | + $json = json_decode( file_get_contents( __DIR__ . '/cldr-data/supplemental/plurals.json' ), true ); |
|
| 285 | + $data[ 'plurals' ] = $fixKeys( $json[ 'supplemental' ][ 'plurals-type-cardinal' ] ); |
|
| 286 | + $json = json_decode( file_get_contents( __DIR__ . '/cldr-data/main/en-US/scripts.json' ), true ); |
|
| 287 | + $data[ 'scripts' ] = $fixKeys( $json[ 'main' ][ 'en-US' ][ 'localeDisplayNames' ][ 'scripts' ], $data[ 'standAloneScripts' ] ); |
|
| 288 | + $data[ 'standAloneScripts' ] = array_merge( $data[ 'scripts' ], $data[ 'standAloneScripts' ] ); |
|
| 289 | + $data[ 'scripts' ] = array_merge( $data[ 'standAloneScripts' ], $data[ 'scripts' ] ); |
|
| 290 | + $data[ 'supersededLanguages' ] = array(); |
|
| 291 | 291 | // Remove the languages for which we don't have plurals |
| 292 | 292 | $m = null; |
| 293 | - foreach (array_keys(array_diff_key($data['languages'], $data['plurals'])) as $missingPlural) { |
|
| 294 | - if (preg_match('/^([a-z]{2,3})_/', $missingPlural, $m)) { |
|
| 295 | - if (!isset($data['plurals'][$m[1]])) { |
|
| 296 | - unset($data['languages'][$missingPlural]); |
|
| 293 | + foreach ( array_keys( array_diff_key( $data[ 'languages' ], $data[ 'plurals' ] ) ) as $missingPlural ) { |
|
| 294 | + if ( preg_match( '/^([a-z]{2,3})_/', $missingPlural, $m ) ) { |
|
| 295 | + if ( ! isset( $data[ 'plurals' ][ $m[ 1 ] ] ) ) { |
|
| 296 | + unset( $data[ 'languages' ][ $missingPlural ] ); |
|
| 297 | 297 | } |
| 298 | 298 | } else { |
| 299 | - unset($data['languages'][$missingPlural]); |
|
| 299 | + unset( $data[ 'languages' ][ $missingPlural ] ); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | // Fix the languages for which we have plurals |
@@ -313,30 +313,30 @@ discard block |
||
| 313 | 313 | 'nah' => 'Nahuatl', |
| 314 | 314 | 'smi' => 'Sami', |
| 315 | 315 | ); |
| 316 | - foreach (array_keys(array_diff_key($data['plurals'], $data['languages'])) as $missingLanguage) { |
|
| 317 | - if (isset($formerCodes[$missingLanguage]) && isset($data['languages'][$formerCodes[$missingLanguage]])) { |
|
| 318 | - $data['languages'][$missingLanguage] = $data['languages'][$formerCodes[$missingLanguage]]; |
|
| 319 | - $data['supersededLanguages'][$missingLanguage] = $formerCodes[$missingLanguage]; |
|
| 316 | + foreach ( array_keys( array_diff_key( $data[ 'plurals' ], $data[ 'languages' ] ) ) as $missingLanguage ) { |
|
| 317 | + if ( isset( $formerCodes[ $missingLanguage ] ) && isset( $data[ 'languages' ][ $formerCodes[ $missingLanguage ] ] ) ) { |
|
| 318 | + $data[ 'languages' ][ $missingLanguage ] = $data[ 'languages' ][ $formerCodes[ $missingLanguage ] ]; |
|
| 319 | + $data[ 'supersededLanguages' ][ $missingLanguage ] = $formerCodes[ $missingLanguage ]; |
|
| 320 | 320 | } else { |
| 321 | - if (isset($knownMissingLanguages[$missingLanguage])) { |
|
| 322 | - $data['languages'][$missingLanguage] = $knownMissingLanguages[$missingLanguage]; |
|
| 321 | + if ( isset( $knownMissingLanguages[ $missingLanguage ] ) ) { |
|
| 322 | + $data[ 'languages' ][ $missingLanguage ] = $knownMissingLanguages[ $missingLanguage ]; |
|
| 323 | 323 | } else { |
| 324 | - throw new Exception("We have the plural rule for the language '{$missingLanguage}' but we don't have its language name"); |
|
| 324 | + throw new Exception( "We have the plural rule for the language '{$missingLanguage}' but we don't have its language name" ); |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | - ksort($data['languages'], SORT_STRING); |
|
| 329 | - ksort($data['territories'], SORT_STRING); |
|
| 330 | - ksort($data['plurals'], SORT_STRING); |
|
| 331 | - ksort($data['scripts'], SORT_STRING); |
|
| 332 | - ksort($data['standAloneScripts'], SORT_STRING); |
|
| 333 | - ksort($data['supersededLanguages'], SORT_STRING); |
|
| 328 | + ksort( $data[ 'languages' ], SORT_STRING ); |
|
| 329 | + ksort( $data[ 'territories' ], SORT_STRING ); |
|
| 330 | + ksort( $data[ 'plurals' ], SORT_STRING ); |
|
| 331 | + ksort( $data[ 'scripts' ], SORT_STRING ); |
|
| 332 | + ksort( $data[ 'standAloneScripts' ], SORT_STRING ); |
|
| 333 | + ksort( $data[ 'supersededLanguages' ], SORT_STRING ); |
|
| 334 | 334 | self::$data = $data; |
| 335 | 335 | } |
| 336 | - if (!isset(self::$data[$key])) { |
|
| 337 | - throw new Exception("Invalid CLDR data key: '{$key}'"); |
|
| 336 | + if ( ! isset( self::$data[ $key ] ) ) { |
|
| 337 | + throw new Exception( "Invalid CLDR data key: '{$key}'" ); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - return self::$data[$key]; |
|
| 340 | + return self::$data[ $key ]; |
|
| 341 | 341 | } |
| 342 | 342 | } |
@@ -21,25 +21,25 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return string[] |
| 23 | 23 | */ |
| 24 | - final public static function getExporters($onlyForPublicUse = false) |
|
| 24 | + final public static function getExporters( $onlyForPublicUse = false ) |
|
| 25 | 25 | { |
| 26 | - if (!isset(self::$exporters)) { |
|
| 26 | + if ( ! isset( self::$exporters ) ) { |
|
| 27 | 27 | $exporters = array(); |
| 28 | 28 | $m = null; |
| 29 | - foreach (scandir(__DIR__) as $f) { |
|
| 30 | - if (preg_match('/^(\w+)\.php$/', $f, $m)) { |
|
| 31 | - if ($f !== basename(__FILE__)) { |
|
| 32 | - $exporters[strtolower($m[1])] = $m[1]; |
|
| 29 | + foreach ( scandir( __DIR__ ) as $f ) { |
|
| 30 | + if ( preg_match( '/^(\w+)\.php$/', $f, $m ) ) { |
|
| 31 | + if ( $f !== basename( __FILE__ ) ) { |
|
| 32 | + $exporters[ strtolower( $m[ 1 ] ) ] = $m[ 1 ]; |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | self::$exporters = $exporters; |
| 37 | 37 | } |
| 38 | - if ($onlyForPublicUse) { |
|
| 38 | + if ( $onlyForPublicUse ) { |
|
| 39 | 39 | $result = array(); |
| 40 | - foreach (self::$exporters as $handle => $class) { |
|
| 41 | - if (call_user_func(self::getExporterClassName($handle) . '::isForPublicUse') === true) { |
|
| 42 | - $result[$handle] = $class; |
|
| 40 | + foreach ( self::$exporters as $handle => $class ) { |
|
| 41 | + if ( call_user_func( self::getExporterClassName( $handle ) . '::isForPublicUse' ) === true ) { |
|
| 42 | + $result[ $handle ] = $class; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } else { |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | - final public static function getExporterDescription($exporterHandle) |
|
| 61 | + final public static function getExporterDescription( $exporterHandle ) |
|
| 62 | 62 | { |
| 63 | 63 | $exporters = self::getExporters(); |
| 64 | - if (!isset($exporters[$exporterHandle])) { |
|
| 65 | - throw new Exception("Invalid exporter handle: '{$exporterHandle}'"); |
|
| 64 | + if ( ! isset( $exporters[ $exporterHandle ] ) ) { |
|
| 65 | + throw new Exception( "Invalid exporter handle: '{$exporterHandle}'" ); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - return call_user_func(self::getExporterClassName($exporterHandle) . '::getDescription'); |
|
| 68 | + return call_user_func( self::getExporterClassName( $exporterHandle ) . '::getDescription' ); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return string |
| 77 | 77 | */ |
| 78 | - final public static function getExporterClassName($exporterHandle) |
|
| 78 | + final public static function getExporterClassName( $exporterHandle ) |
|
| 79 | 79 | { |
| 80 | - return __NAMESPACE__ . '\\' . ucfirst(strtolower($exporterHandle)); |
|
| 80 | + return __NAMESPACE__ . '\\' . ucfirst( strtolower( $exporterHandle ) ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string |
| 90 | 90 | */ |
| 91 | - final public static function toString($languages, $options = null) |
|
| 91 | + final public static function toString( $languages, $options = null ) |
|
| 92 | 92 | { |
| 93 | - if (isset($options) && is_array($options)) { |
|
| 94 | - if (isset($options['us-ascii']) && $options['us-ascii']) { |
|
| 93 | + if ( isset( $options ) && is_array( $options ) ) { |
|
| 94 | + if ( isset( $options[ 'us-ascii' ] ) && $options[ 'us-ascii' ] ) { |
|
| 95 | 95 | $asciiList = array(); |
| 96 | - foreach ($languages as $language) { |
|
| 97 | - $asciiList[] = $language->getUSAsciiClone(); |
|
| 96 | + foreach ( $languages as $language ) { |
|
| 97 | + $asciiList[ ] = $language->getUSAsciiClone(); |
|
| 98 | 98 | } |
| 99 | 99 | $languages = $asciiList; |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - return static::toStringDo($languages); |
|
| 103 | + return static::toStringDo( $languages ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @throws \Exception |
| 113 | 113 | */ |
| 114 | - final public static function toFile($languages, $filename, $options = null) |
|
| 114 | + final public static function toFile( $languages, $filename, $options = null ) |
|
| 115 | 115 | { |
| 116 | - $data = self::toString($languages, $options); |
|
| 117 | - if (@file_put_contents($filename, $data) === false) { |
|
| 118 | - throw new Exception("Error writing data to '{$filename}'"); |
|
| 116 | + $data = self::toString( $languages, $options ); |
|
| 117 | + if ( @file_put_contents( $filename, $data ) === false ) { |
|
| 118 | + throw new Exception( "Error writing data to '{$filename}'" ); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public static function getDescription() |
| 138 | 138 | { |
| 139 | - throw new Exception(get_called_class() . ' does not implement the method ' . __FUNCTION__); |
|
| 139 | + throw new Exception( get_called_class() . ' does not implement the method ' . __FUNCTION__ ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return string |
| 148 | 148 | */ |
| 149 | - protected static function toStringDo($languages) |
|
| 149 | + protected static function toStringDo( $languages ) |
|
| 150 | 150 | { |
| 151 | - throw new Exception(get_called_class() . ' does not implement the method ' . __FUNCTION__); |
|
| 151 | + throw new Exception( get_called_class() . ' does not implement the method ' . __FUNCTION__ ); |
|
| 152 | 152 | } |
| 153 | 153 | } |
@@ -19,51 +19,51 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
| 21 | 21 | */ |
| 22 | - protected static function toStringDo($languages) |
|
| 22 | + protected static function toStringDo( $languages ) |
|
| 23 | 23 | { |
| 24 | - return self::buildTable($languages, false); |
|
| 24 | + return self::buildTable( $languages, false ); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - protected static function h($str) |
|
| 27 | + protected static function h( $str ) |
|
| 28 | 28 | { |
| 29 | - return htmlspecialchars($str, ENT_COMPAT, 'UTF-8'); |
|
| 29 | + return htmlspecialchars( $str, ENT_COMPAT, 'UTF-8' ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - protected static function buildTable($languages, $forDocs) |
|
| 32 | + protected static function buildTable( $languages, $forDocs ) |
|
| 33 | 33 | { |
| 34 | 34 | $prefix = $forDocs ? ' ' : ''; |
| 35 | 35 | $lines = array(); |
| 36 | - $lines[] = $prefix . '<table' . ($forDocs ? ' class="table table-bordered table-condensed table-striped"' : '') . '>'; |
|
| 37 | - $lines[] = $prefix . ' <thead>'; |
|
| 38 | - $lines[] = $prefix . ' <tr>'; |
|
| 39 | - $lines[] = $prefix . ' <th>Language code</th>'; |
|
| 40 | - $lines[] = $prefix . ' <th>Language name</th>'; |
|
| 41 | - $lines[] = $prefix . ' <th># plurals</th>'; |
|
| 42 | - $lines[] = $prefix . ' <th>Formula</th>'; |
|
| 43 | - $lines[] = $prefix . ' <th>Plurals</th>'; |
|
| 44 | - $lines[] = $prefix . ' </tr>'; |
|
| 45 | - $lines[] = $prefix . ' </thead>'; |
|
| 46 | - $lines[] = $prefix . ' <tbody>'; |
|
| 47 | - foreach ($languages as $lc) { |
|
| 48 | - $lines[] = $prefix . ' <tr>'; |
|
| 49 | - $lines[] = $prefix . ' <td>' . $lc->id . '</td>'; |
|
| 50 | - $name = self::h($lc->name); |
|
| 51 | - if (isset($lc->supersededBy)) { |
|
| 36 | + $lines[ ] = $prefix . '<table' . ( $forDocs ? ' class="table table-bordered table-condensed table-striped"' : '' ) . '>'; |
|
| 37 | + $lines[ ] = $prefix . ' <thead>'; |
|
| 38 | + $lines[ ] = $prefix . ' <tr>'; |
|
| 39 | + $lines[ ] = $prefix . ' <th>Language code</th>'; |
|
| 40 | + $lines[ ] = $prefix . ' <th>Language name</th>'; |
|
| 41 | + $lines[ ] = $prefix . ' <th># plurals</th>'; |
|
| 42 | + $lines[ ] = $prefix . ' <th>Formula</th>'; |
|
| 43 | + $lines[ ] = $prefix . ' <th>Plurals</th>'; |
|
| 44 | + $lines[ ] = $prefix . ' </tr>'; |
|
| 45 | + $lines[ ] = $prefix . ' </thead>'; |
|
| 46 | + $lines[ ] = $prefix . ' <tbody>'; |
|
| 47 | + foreach ( $languages as $lc ) { |
|
| 48 | + $lines[ ] = $prefix . ' <tr>'; |
|
| 49 | + $lines[ ] = $prefix . ' <td>' . $lc->id . '</td>'; |
|
| 50 | + $name = self::h( $lc->name ); |
|
| 51 | + if ( isset( $lc->supersededBy ) ) { |
|
| 52 | 52 | $name .= '<br /><small><span>Superseded by</span> ' . $lc->supersededBy . '</small>'; |
| 53 | 53 | } |
| 54 | - $lines[] = $prefix . ' <td>' . $name . '</td>'; |
|
| 55 | - $lines[] = $prefix . ' <td>' . count($lc->categories) . '</td>'; |
|
| 56 | - $lines[] = $prefix . ' <td>' . self::h($lc->formula) . '</td>'; |
|
| 54 | + $lines[ ] = $prefix . ' <td>' . $name . '</td>'; |
|
| 55 | + $lines[ ] = $prefix . ' <td>' . count( $lc->categories ) . '</td>'; |
|
| 56 | + $lines[ ] = $prefix . ' <td>' . self::h( $lc->formula ) . '</td>'; |
|
| 57 | 57 | $cases = array(); |
| 58 | - foreach ($lc->categories as $c) { |
|
| 59 | - $cases[] = '<li><span>' . $c->id . '</span><code>' . self::h($c->examples) . '</code></li>'; |
|
| 58 | + foreach ( $lc->categories as $c ) { |
|
| 59 | + $cases[ ] = '<li><span>' . $c->id . '</span><code>' . self::h( $c->examples ) . '</code></li>'; |
|
| 60 | 60 | } |
| 61 | - $lines[] = $prefix . ' <td><ol' . ($forDocs ? ' class="cases"' : '') . ' start="0">' . implode('', $cases) . '</ol></td>'; |
|
| 62 | - $lines[] = $prefix . ' </tr>'; |
|
| 61 | + $lines[ ] = $prefix . ' <td><ol' . ( $forDocs ? ' class="cases"' : '' ) . ' start="0">' . implode( '', $cases ) . '</ol></td>'; |
|
| 62 | + $lines[ ] = $prefix . ' </tr>'; |
|
| 63 | 63 | } |
| 64 | - $lines[] = $prefix . ' </tbody>'; |
|
| 65 | - $lines[] = $prefix . '</table>'; |
|
| 64 | + $lines[ ] = $prefix . ' </tbody>'; |
|
| 65 | + $lines[ ] = $prefix . '</table>'; |
|
| 66 | 66 | |
| 67 | - return implode("\n", $lines); |
|
| 67 | + return implode( "\n", $lines ); |
|
| 68 | 68 | } |
| 69 | 69 | } |
@@ -19,39 +19,39 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
| 21 | 21 | */ |
| 22 | - protected static function toStringDo($languages) |
|
| 22 | + protected static function toStringDo( $languages ) |
|
| 23 | 23 | { |
| 24 | - $xml = new \DOMDocument('1.0', 'UTF-8'); |
|
| 25 | - $xml->loadXML('<languages |
|
| 24 | + $xml = new \DOMDocument( '1.0', 'UTF-8' ); |
|
| 25 | + $xml->loadXML( '<languages |
|
| 26 | 26 | xmlns="https://github.com/mlocati/cldr-to-gettext-plural-rules" |
| 27 | 27 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 28 | 28 | xsi:schemaLocation="https://github.com/mlocati/cldr-to-gettext-plural-rules http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd" |
| 29 | 29 | />'); |
| 30 | 30 | $xLanguages = $xml->firstChild; |
| 31 | - foreach ($languages as $language) { |
|
| 32 | - $xLanguage = $xml->createElement('language'); |
|
| 33 | - $xLanguage->setAttribute('id', $language->id); |
|
| 34 | - $xLanguage->setAttribute('name', $language->name); |
|
| 35 | - if (isset($language->supersededBy)) { |
|
| 36 | - $xLanguage->setAttribute('supersededBy', $language->supersededBy); |
|
| 31 | + foreach ( $languages as $language ) { |
|
| 32 | + $xLanguage = $xml->createElement( 'language' ); |
|
| 33 | + $xLanguage->setAttribute( 'id', $language->id ); |
|
| 34 | + $xLanguage->setAttribute( 'name', $language->name ); |
|
| 35 | + if ( isset( $language->supersededBy ) ) { |
|
| 36 | + $xLanguage->setAttribute( 'supersededBy', $language->supersededBy ); |
|
| 37 | 37 | } |
| 38 | - if (isset($language->script)) { |
|
| 39 | - $xLanguage->setAttribute('script', $language->script); |
|
| 38 | + if ( isset( $language->script ) ) { |
|
| 39 | + $xLanguage->setAttribute( 'script', $language->script ); |
|
| 40 | 40 | } |
| 41 | - if (isset($language->territory)) { |
|
| 42 | - $xLanguage->setAttribute('territory', $language->territory); |
|
| 41 | + if ( isset( $language->territory ) ) { |
|
| 42 | + $xLanguage->setAttribute( 'territory', $language->territory ); |
|
| 43 | 43 | } |
| 44 | - if (isset($language->baseLanguage)) { |
|
| 45 | - $xLanguage->setAttribute('baseLanguage', $language->baseLanguage); |
|
| 44 | + if ( isset( $language->baseLanguage ) ) { |
|
| 45 | + $xLanguage->setAttribute( 'baseLanguage', $language->baseLanguage ); |
|
| 46 | 46 | } |
| 47 | - $xLanguage->setAttribute('formula', $language->formula); |
|
| 48 | - foreach ($language->categories as $category) { |
|
| 49 | - $xCategory = $xml->createElement('category'); |
|
| 50 | - $xCategory->setAttribute('id', $category->id); |
|
| 51 | - $xCategory->setAttribute('examples', $category->examples); |
|
| 52 | - $xLanguage->appendChild($xCategory); |
|
| 47 | + $xLanguage->setAttribute( 'formula', $language->formula ); |
|
| 48 | + foreach ( $language->categories as $category ) { |
|
| 49 | + $xCategory = $xml->createElement( 'category' ); |
|
| 50 | + $xCategory->setAttribute( 'id', $category->id ); |
|
| 51 | + $xCategory->setAttribute( 'examples', $category->examples ); |
|
| 52 | + $xLanguage->appendChild( $xCategory ); |
|
| 53 | 53 | } |
| 54 | - $xLanguages->appendChild($xLanguage); |
|
| 54 | + $xLanguages->appendChild( $xLanguage ); |
|
| 55 | 55 | } |
| 56 | 56 | $xml->formatOutput = true; |
| 57 | 57 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
| 31 | 31 | */ |
| 32 | - protected static function toStringDo($languages) |
|
| 32 | + protected static function toStringDo( $languages ) |
|
| 33 | 33 | { |
| 34 | 34 | $result = <<<'EOT' |
| 35 | 35 | <!doctype html> |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | <div class="container-fluid"> |
| 50 | 50 | |
| 51 | 51 | EOT; |
| 52 | - $result .= static::buildTable($languages, true); |
|
| 52 | + $result .= static::buildTable( $languages, true ); |
|
| 53 | 53 | $result .= <<<'EOT' |
| 54 | 54 | |
| 55 | 55 | </div> |
@@ -21,17 +21,17 @@ |
||
| 21 | 21 | * |
| 22 | 22 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
| 23 | 23 | */ |
| 24 | - protected static function toStringDo($languages) |
|
| 24 | + protected static function toStringDo( $languages ) |
|
| 25 | 25 | { |
| 26 | - if (count($languages) !== 1) { |
|
| 27 | - throw new Exception('The ' . get_called_class() . ' exporter can only export one language'); |
|
| 26 | + if ( count( $languages ) !== 1 ) { |
|
| 27 | + throw new Exception( 'The ' . get_called_class() . ' exporter can only export one language' ); |
|
| 28 | 28 | } |
| 29 | - $language = $languages[0]; |
|
| 29 | + $language = $languages[ 0 ]; |
|
| 30 | 30 | $lines = array(); |
| 31 | - $lines[] = '"Language: ' . $language->id . '\n"'; |
|
| 32 | - $lines[] = '"Plural-Forms: nplurals=' . count($language->categories) . '; plural=' . $language->formula . '\n"'; |
|
| 33 | - $lines[] = ''; |
|
| 31 | + $lines[ ] = '"Language: ' . $language->id . '\n"'; |
|
| 32 | + $lines[ ] = '"Plural-Forms: nplurals=' . count( $language->categories ) . '; plural=' . $language->formula . '\n"'; |
|
| 33 | + $lines[ ] = ''; |
|
| 34 | 34 | |
| 35 | - return implode("\n", $lines); |
|
| 35 | + return implode( "\n", $lines ); |
|
| 36 | 36 | } |
| 37 | 37 | } |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | protected static function getEncodeOptions() |
| 23 | 23 | { |
| 24 | 24 | $result = 0; |
| 25 | - if (defined('\JSON_UNESCAPED_SLASHES')) { |
|
| 25 | + if ( defined( '\JSON_UNESCAPED_SLASHES' ) ) { |
|
| 26 | 26 | $result |= \JSON_UNESCAPED_SLASHES; |
| 27 | 27 | } |
| 28 | - if (defined('\JSON_UNESCAPED_UNICODE')) { |
|
| 28 | + if ( defined( '\JSON_UNESCAPED_UNICODE' ) ) { |
|
| 29 | 29 | $result |= \JSON_UNESCAPED_UNICODE; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -37,35 +37,35 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
| 39 | 39 | */ |
| 40 | - protected static function toStringDo($languages) |
|
| 40 | + protected static function toStringDo( $languages ) |
|
| 41 | 41 | { |
| 42 | 42 | $list = array(); |
| 43 | - foreach ($languages as $language) { |
|
| 43 | + foreach ( $languages as $language ) { |
|
| 44 | 44 | $item = array(); |
| 45 | - $item['name'] = $language->name; |
|
| 46 | - if (isset($language->supersededBy)) { |
|
| 47 | - $item['supersededBy'] = $language->supersededBy; |
|
| 45 | + $item[ 'name' ] = $language->name; |
|
| 46 | + if ( isset( $language->supersededBy ) ) { |
|
| 47 | + $item[ 'supersededBy' ] = $language->supersededBy; |
|
| 48 | 48 | } |
| 49 | - if (isset($language->script)) { |
|
| 50 | - $item['script'] = $language->script; |
|
| 49 | + if ( isset( $language->script ) ) { |
|
| 50 | + $item[ 'script' ] = $language->script; |
|
| 51 | 51 | } |
| 52 | - if (isset($language->territory)) { |
|
| 53 | - $item['territory'] = $language->territory; |
|
| 52 | + if ( isset( $language->territory ) ) { |
|
| 53 | + $item[ 'territory' ] = $language->territory; |
|
| 54 | 54 | } |
| 55 | - if (isset($language->baseLanguage)) { |
|
| 56 | - $item['baseLanguage'] = $language->baseLanguage; |
|
| 55 | + if ( isset( $language->baseLanguage ) ) { |
|
| 56 | + $item[ 'baseLanguage' ] = $language->baseLanguage; |
|
| 57 | 57 | } |
| 58 | - $item['formula'] = $language->formula; |
|
| 59 | - $item['plurals'] = count($language->categories); |
|
| 60 | - $item['cases'] = array(); |
|
| 61 | - $item['examples'] = array(); |
|
| 62 | - foreach ($language->categories as $category) { |
|
| 63 | - $item['cases'][] = $category->id; |
|
| 64 | - $item['examples'][$category->id] = $category->examples; |
|
| 58 | + $item[ 'formula' ] = $language->formula; |
|
| 59 | + $item[ 'plurals' ] = count( $language->categories ); |
|
| 60 | + $item[ 'cases' ] = array(); |
|
| 61 | + $item[ 'examples' ] = array(); |
|
| 62 | + foreach ( $language->categories as $category ) { |
|
| 63 | + $item[ 'cases' ][ ] = $category->id; |
|
| 64 | + $item[ 'examples' ][ $category->id ] = $category->examples; |
|
| 65 | 65 | } |
| 66 | - $list[$language->id] = $item; |
|
| 66 | + $list[ $language->id ] = $item; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - return json_encode($list, static::getEncodeOptions()); |
|
| 69 | + return json_encode( $list, static::getEncodeOptions() ); |
|
| 70 | 70 | } |
| 71 | 71 | } |
@@ -19,43 +19,43 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @see \Gettext\Languages\Exporter\Exporter::toStringDo() |
| 21 | 21 | */ |
| 22 | - protected static function toStringDo($languages) |
|
| 22 | + protected static function toStringDo( $languages ) |
|
| 23 | 23 | { |
| 24 | 24 | $lines = array(); |
| 25 | - $lines[] = '<?php'; |
|
| 26 | - $lines[] = 'return array('; |
|
| 27 | - foreach ($languages as $lc) { |
|
| 28 | - $lines[] = ' \'' . $lc->id . '\' => array('; |
|
| 29 | - $lines[] = ' \'name\' => \'' . addslashes($lc->name) . '\','; |
|
| 30 | - if (isset($lc->supersededBy)) { |
|
| 31 | - $lines[] = ' \'supersededBy\' => \'' . $lc->supersededBy . '\','; |
|
| 25 | + $lines[ ] = '<?php'; |
|
| 26 | + $lines[ ] = 'return array('; |
|
| 27 | + foreach ( $languages as $lc ) { |
|
| 28 | + $lines[ ] = ' \'' . $lc->id . '\' => array('; |
|
| 29 | + $lines[ ] = ' \'name\' => \'' . addslashes( $lc->name ) . '\','; |
|
| 30 | + if ( isset( $lc->supersededBy ) ) { |
|
| 31 | + $lines[ ] = ' \'supersededBy\' => \'' . $lc->supersededBy . '\','; |
|
| 32 | 32 | } |
| 33 | - if (isset($lc->script)) { |
|
| 34 | - $lines[] = ' \'script\' => \'' . addslashes($lc->script) . '\','; |
|
| 33 | + if ( isset( $lc->script ) ) { |
|
| 34 | + $lines[ ] = ' \'script\' => \'' . addslashes( $lc->script ) . '\','; |
|
| 35 | 35 | } |
| 36 | - if (isset($lc->territory)) { |
|
| 37 | - $lines[] = ' \'territory\' => \'' . addslashes($lc->territory) . '\','; |
|
| 36 | + if ( isset( $lc->territory ) ) { |
|
| 37 | + $lines[ ] = ' \'territory\' => \'' . addslashes( $lc->territory ) . '\','; |
|
| 38 | 38 | } |
| 39 | - if (isset($lc->baseLanguage)) { |
|
| 40 | - $lines[] = ' \'baseLanguage\' => \'' . addslashes($lc->baseLanguage) . '\','; |
|
| 39 | + if ( isset( $lc->baseLanguage ) ) { |
|
| 40 | + $lines[ ] = ' \'baseLanguage\' => \'' . addslashes( $lc->baseLanguage ) . '\','; |
|
| 41 | 41 | } |
| 42 | - $lines[] = ' \'formula\' => \'' . $lc->formula . '\','; |
|
| 43 | - $lines[] = ' \'plurals\' => ' . count($lc->categories) . ','; |
|
| 42 | + $lines[ ] = ' \'formula\' => \'' . $lc->formula . '\','; |
|
| 43 | + $lines[ ] = ' \'plurals\' => ' . count( $lc->categories ) . ','; |
|
| 44 | 44 | $catNames = array(); |
| 45 | - foreach ($lc->categories as $c) { |
|
| 46 | - $catNames[] = "'{$c->id}'"; |
|
| 45 | + foreach ( $lc->categories as $c ) { |
|
| 46 | + $catNames[ ] = "'{$c->id}'"; |
|
| 47 | 47 | } |
| 48 | - $lines[] = ' \'cases\' => array(' . implode(', ', $catNames) . '),'; |
|
| 49 | - $lines[] = ' \'examples\' => array('; |
|
| 50 | - foreach ($lc->categories as $c) { |
|
| 51 | - $lines[] = ' \'' . $c->id . '\' => \'' . $c->examples . '\','; |
|
| 48 | + $lines[ ] = ' \'cases\' => array(' . implode( ', ', $catNames ) . '),'; |
|
| 49 | + $lines[ ] = ' \'examples\' => array('; |
|
| 50 | + foreach ( $lc->categories as $c ) { |
|
| 51 | + $lines[ ] = ' \'' . $c->id . '\' => \'' . $c->examples . '\','; |
|
| 52 | 52 | } |
| 53 | - $lines[] = ' ),'; |
|
| 54 | - $lines[] = ' ),'; |
|
| 53 | + $lines[ ] = ' ),'; |
|
| 54 | + $lines[ ] = ' ),'; |
|
| 55 | 55 | } |
| 56 | - $lines[] = ');'; |
|
| 57 | - $lines[] = ''; |
|
| 56 | + $lines[ ] = ');'; |
|
| 57 | + $lines[ ] = ''; |
|
| 58 | 58 | |
| 59 | - return implode("\n", $lines); |
|
| 59 | + return implode( "\n", $lines ); |
|
| 60 | 60 | } |
| 61 | 61 | } |