@@ -15,12 +15,12 @@ |
||
| 15 | 15 | protected function parseDefinition() : void |
| 16 | 16 | { |
| 17 | 17 | // some entries are strings, like parentheses, semicolons and the like. |
| 18 | - if(is_string($this->definition)) |
|
| 18 | + if (is_string($this->definition)) |
|
| 19 | 19 | { |
| 20 | 20 | $this->token = $this->definition; |
| 21 | 21 | $this->value = null; |
| 22 | 22 | |
| 23 | - if(isset($this->parentToken)) { |
|
| 23 | + if (isset($this->parentToken)) { |
|
| 24 | 24 | $this->line = $this->parentToken->getLine(); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | public function getProperty(string $name) : ?string |
| 89 | 89 | { |
| 90 | - if(isset($this->properties[$name])) { |
|
| 90 | + if (isset($this->properties[$name])) { |
|
| 91 | 91 | return $this->properties[$name]; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | Text::fromArray($array[self::SERIALIZED_TEXT]) |
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | - foreach($array[self::SERIALIZED_PROPERTIES] as $name => $value) { |
|
| 144 | + foreach ($array[self::SERIALIZED_PROPERTIES] as $name => $value) { |
|
| 145 | 145 | $string->setProperty($name, $value); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $entries = array(); |
| 52 | 52 | |
| 53 | - foreach($this->strings as $string) { |
|
| 53 | + foreach ($this->strings as $string) { |
|
| 54 | 54 | $entries[] = $string->toArray(); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $amount = 0; |
| 72 | 72 | |
| 73 | - foreach($this->strings as $string) { |
|
| 74 | - if($string->isFile()) { |
|
| 73 | + foreach ($this->strings as $string) { |
|
| 74 | + if ($string->isFile()) { |
|
| 75 | 75 | $amount++; |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | public function hasLanguageType(string $type) : bool |
| 88 | 88 | { |
| 89 | - foreach($this->strings as $string) { |
|
| 90 | - if($string->getLanguageType() == $type) { |
|
| 89 | + foreach ($this->strings as $string) { |
|
| 90 | + if ($string->getLanguageType() == $type) { |
|
| 91 | 91 | return true; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | public function getText() : ?Text |
| 99 | 99 | { |
| 100 | - if(isset($this->strings[0])) { |
|
| 100 | + if (isset($this->strings[0])) { |
|
| 101 | 101 | return $this->strings[0]->getText(); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $translator = Localization::getTranslator(); |
| 130 | 130 | $text = $translator->getHashTranslation($this->getHash()); |
| 131 | 131 | |
| 132 | - if($text !== null) { |
|
| 132 | + if ($text !== null) { |
|
| 133 | 133 | return $text; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | $files = array(); |
| 146 | 146 | |
| 147 | - foreach($this->strings as $string) |
|
| 147 | + foreach ($this->strings as $string) |
|
| 148 | 148 | { |
| 149 | - if(!$string->isFile()) { |
|
| 149 | + if (!$string->isFile()) { |
|
| 150 | 150 | continue; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $file = $string->getSourceFile(); |
| 154 | - if(!in_array($file, $files)) { |
|
| 154 | + if (!in_array($file, $files)) { |
|
| 155 | 155 | $files[] = $file; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $files = $this->getFiles(); |
| 171 | 171 | $result = array(); |
| 172 | 172 | |
| 173 | - foreach($files as $path) { |
|
| 173 | + foreach ($files as $path) { |
|
| 174 | 174 | $result[] = basename($path); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -54,7 +54,7 @@ |
||
| 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 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -42,13 +42,13 @@ |
||
| 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 | |
@@ -31,7 +31,7 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function scan() : void |
| 74 | 74 | { |
| 75 | - if(isset($this->collection)) { |
|
| 75 | + if (isset($this->collection)) { |
|
| 76 | 76 | $this->collection = null; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $this->timeStart = microtime(true); |
| 80 | 80 | |
| 81 | 81 | $sources = Localization::getSources(); |
| 82 | - foreach($sources as $source) |
|
| 82 | + foreach ($sources as $source) |
|
| 83 | 83 | { |
| 84 | 84 | $source->scan($this); |
| 85 | 85 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | public function load() : void |
| 93 | 93 | { |
| 94 | - if(!$this->isScanAvailable()) { |
|
| 94 | + if (!$this->isScanAvailable()) { |
|
| 95 | 95 | return; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if($this->loaded) { |
|
| 98 | + if ($this->loaded) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | $data = FileHelper::parseJSONFile($this->storageFile); |
| 105 | 105 | |
| 106 | - if($this->getCollection()->fromArray($data) === true) { |
|
| 106 | + if ($this->getCollection()->fromArray($data) === true) { |
|
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public function getParser() : Localization_Parser |
| 123 | 123 | { |
| 124 | - if(!isset($this->parser)) { |
|
| 124 | + if (!isset($this->parser)) { |
|
| 125 | 125 | $this->parser = new Localization_Parser($this); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | public function getCollection() : Localization_Scanner_StringsCollection |
| 132 | 132 | { |
| 133 | - if(!isset($this->collection)) { |
|
| 133 | + if (!isset($this->collection)) { |
|
| 134 | 134 | $this->collection = new Localization_Scanner_StringsCollection($this); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | return self::$instances[$id]; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $className = Localization_Currency::class.'_' . $id; |
|
| 76 | + $className = Localization_Currency::class.'_'.$id; |
|
| 77 | 77 | |
| 78 | 78 | $country = new $className($country); |
| 79 | 79 | |
| 80 | - if($country instanceof Localization_Currency) |
|
| 80 | + if ($country instanceof Localization_Currency) |
|
| 81 | 81 | { |
| 82 | 82 | return $country; |
| 83 | 83 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public static function isCurrencyKnown(string $currencyName) : bool |
| 140 | 140 | { |
| 141 | - return file_exists(__DIR__ . '/Currency/' . $currencyName . '.php'); |
|
| 141 | + return file_exists(__DIR__.'/Currency/'.$currencyName.'.php'); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @return string |
| 351 | 351 | * @throws Localization_Exception |
| 352 | 352 | */ |
| 353 | - public function makeReadable($number, int $decimalPositions = 2, bool $addSymbol=true) : string |
|
| 353 | + public function makeReadable($number, int $decimalPositions = 2, bool $addSymbol = true) : string |
|
| 354 | 354 | { |
| 355 | 355 | if ($number === null || $number === '') { |
| 356 | 356 | return ''; |
@@ -360,14 +360,14 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | $number = $this->formatNumber($parsed->getFloat(), $decimalPositions); |
| 362 | 362 | |
| 363 | - if(!$addSymbol) { |
|
| 363 | + if (!$addSymbol) { |
|
| 364 | 364 | return $number; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | if ($this->isSymbolOnFront()) { |
| 368 | - return $this->getSymbol() . ' ' . $number; |
|
| 368 | + return $this->getSymbol().' '.$number; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - return $number . ' ' . $this->getSymbol(); |
|
| 371 | + return $number.' '.$this->getSymbol(); |
|
| 372 | 372 | } |
| 373 | 373 | } |