@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | const BUILD_DIRECTORY = __DIR__ . '/build'; |
| 14 | 14 | const DATA_DIRECTORY = __DIR__ . '/node_modules/emojibase-data'; |
| 15 | 15 | |
| 16 | -if (! is_dir(DATA_DIRECTORY) || ! interface_exists(EmojibaseInterface::class)) { |
|
| 16 | +if (!is_dir(DATA_DIRECTORY) || !interface_exists(EmojibaseInterface::class)) { |
|
| 17 | 17 | throw new \RuntimeException('You must first run `npm install && npm run build` to build the datasets.'); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | $data = array_column($json, null, 'hexcode'); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if (! isset($data)) { |
|
| 31 | + if (!isset($data)) { |
|
| 32 | 32 | throw new \RuntimeException(sprintf('Unable to load JSON: %s', $file)); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Merge any skin variations into the main list (faster performance). |
| 36 | 36 | foreach ($data as $hexcode => &$item) { |
| 37 | - if (! isset($item['shortcodes'])) { |
|
| 37 | + if (!isset($item['shortcodes'])) { |
|
| 38 | 38 | $item['shortcodes'] = []; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $item['shortcodes'] = Emoji::normalizeShortcodes($item['shortcodes'], $shortcodes[$hexcode]); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (! isset($item['skins']) || ! count($item['skins'])) { |
|
| 47 | + if (!isset($item['skins']) || !count($item['skins'])) { |
|
| 48 | 48 | continue; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | foreach (EmojibaseInterface::SHORTCODE_PRESETS as $preset) { |
| 88 | 88 | // Skip presets that don't exist. |
| 89 | 89 | $file = sprintf('%s/%s/shortcodes/%s.json', DATA_DIRECTORY, $locale, $preset); |
| 90 | - if (! file_exists($file) || ! ($c = file_get_contents($file)) || ! ($shortcodes = json_decode($c, true))) { |
|
| 90 | + if (!file_exists($file) || !($c = file_get_contents($file)) || !($shortcodes = json_decode($c, true))) { |
|
| 91 | 91 | continue; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | |
| 39 | 39 | $tokens = []; |
| 40 | 40 | while (true) { |
| 41 | - if (! $this->lookahead) { |
|
| 41 | + if (!$this->lookahead) { |
|
| 42 | 42 | break; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @return string[] |
| 87 | 87 | */ |
| 88 | - static function (Options $options, $value): array { |
|
| 89 | - if (! $value) { |
|
| 88 | + static function(Options $options, $value): array { |
|
| 89 | + if (!$value) { |
|
| 90 | 90 | return $value; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -96,20 +96,20 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $resolver->define('locale') |
| 98 | 98 | ->allowedTypes('string') |
| 99 | - ->allowedValues(static function (string $value): bool { |
|
| 100 | - return ! ! static::normalizeLocale($value); |
|
| 99 | + ->allowedValues(static function(string $value): bool { |
|
| 100 | + return !!static::normalizeLocale($value); |
|
| 101 | 101 | }) |
| 102 | 102 | ->default('en') |
| 103 | - ->normalize(static function (Options $options, string $value): string { |
|
| 103 | + ->normalize(static function(Options $options, string $value): string { |
|
| 104 | 104 | return static::normalizeLocale($value); |
| 105 | 105 | }); |
| 106 | 106 | |
| 107 | 107 | $resolver->define('native') |
| 108 | 108 | ->allowedTypes('bool') |
| 109 | - ->default(static function (Options $options): bool { |
|
| 109 | + ->default(static function(Options $options): bool { |
|
| 110 | 110 | return \in_array($options['locale'], EmojibaseInterface::NON_LATIN_LOCALES, true); |
| 111 | 111 | }) |
| 112 | - ->normalize(static function (Options $options, bool $value) { |
|
| 112 | + ->normalize(static function(Options $options, bool $value) { |
|
| 113 | 113 | return $value && \in_array($options['locale'], EmojibaseInterface::NON_LATIN_LOCALES, true); |
| 114 | 114 | }); |
| 115 | 115 | |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | /** |
| 125 | 125 | * @param mixed $value |
| 126 | 126 | */ |
| 127 | - static function ($value): bool { |
|
| 127 | + static function($value): bool { |
|
| 128 | 128 | foreach ((array) $value as $v) { |
| 129 | - if (! \in_array($v, EmojibaseInterface::SUPPORTED_SHORTCODE_PRESETS, true)) { |
|
| 129 | + if (!\in_array($v, EmojibaseInterface::SUPPORTED_SHORTCODE_PRESETS, true)) { |
|
| 130 | 130 | throw new InvalidOptionsException(\sprintf( |
| 131 | 131 | 'The option "preset" with value "%s" is invalid. Accepted values are: %s.', |
| 132 | 132 | $v, |
| 133 | - \implode(', ', \array_map(static function ($s) { |
|
| 133 | + \implode(', ', \array_map(static function($s) { |
|
| 134 | 134 | return \sprintf('"%s"', $s); |
| 135 | 135 | }, EmojibaseInterface::SUPPORTED_SHORTCODE_PRESETS)) |
| 136 | 136 | )); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return string[] |
| 149 | 149 | */ |
| 150 | - static function (Options $options, $value): array { |
|
| 150 | + static function(Options $options, $value): array { |
|
| 151 | 151 | // Presets. |
| 152 | 152 | $presets = []; |
| 153 | 153 | foreach ((array) $value as $preset) { |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public static function assertEmojis(array $emojis = []): array |
| 29 | 29 | { |
| 30 | 30 | foreach ($emojis as $emoji) { |
| 31 | - if (! $emoji instanceof Emoji) { |
|
| 31 | + if (!$emoji instanceof Emoji) { |
|
| 32 | 32 | throw new \RuntimeException(\sprintf('Passed array item must be an instance of %s.', Emoji::class)); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } elseif ($emojis instanceof Emoji) { |
| 73 | 73 | $emojis = [$emojis]; |
| 74 | 74 | } else { |
| 75 | - $emojis = \array_map(static function ($emoji) { |
|
| 75 | + $emojis = \array_map(static function($emoji) { |
|
| 76 | 76 | return \is_array($emoji) ? Emoji::create($emoji) : $emoji; |
| 77 | 77 | }, (array) $emojis); |
| 78 | 78 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | foreach ($emoji->getSkins() as $skin) { |
| 90 | 90 | $skinKeys = \array_filter((array) $skin[$key]); |
| 91 | 91 | foreach ($skinKeys as $sk) { |
| 92 | - if (! isset($collection[$sk])) { |
|
| 92 | + if (!isset($collection[$sk])) { |
|
| 93 | 93 | $collection[$sk] = $skin; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | $this->configuration->get('locale'), |
| 26 | 26 | $this->configuration->get('preset') |
| 27 | 27 | ); |
| 28 | - $this->parser = $parser ?? new Parser($this->configuration); |
|
| 28 | + $this->parser = $parser ?? new Parser($this->configuration); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $normalized = \array_values(\array_unique(\array_merge( |
| 227 | 227 | $normalized, |
| 228 | 228 | \array_map( |
| 229 | - static function ($shortcode) { |
|
| 229 | + static function($shortcode) { |
|
| 230 | 230 | return \preg_replace('/[^a-z0-9-]/', '-', \strtolower(\trim($shortcode, ':(){}[]'))); |
| 231 | 231 | }, |
| 232 | 232 | (array) $shortcodes |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | { |
| 312 | 312 | return \current( |
| 313 | 313 | $this->getSkins()->filter( |
| 314 | - static function (Emoji $emoji) use ($tone) { |
|
| 314 | + static function(Emoji $emoji) use ($tone) { |
|
| 315 | 315 | return \in_array($tone, (array) $emoji->getTone(), true); |
| 316 | 316 | } |
| 317 | 317 | )->getArrayCopy() |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | public function offsetExists($key): bool // phpcs:ignore |
| 375 | 375 | { |
| 376 | - $method = \current(\array_filter(['get' . \ucfirst($key), $key], function ($method) { |
|
| 376 | + $method = \current(\array_filter(['get' . \ucfirst($key), $key], function($method) { |
|
| 377 | 377 | return \method_exists($this, $method); |
| 378 | 378 | })); |
| 379 | 379 | |
@@ -392,12 +392,12 @@ discard block |
||
| 392 | 392 | public function offsetGet($key) // phpcs:ignore |
| 393 | 393 | { |
| 394 | 394 | // Use the dedicated "get" method for the property instead. |
| 395 | - $method = \current(\array_filter(['get' . \ucfirst($key), $key], function ($method) { |
|
| 395 | + $method = \current(\array_filter(['get' . \ucfirst($key), $key], function($method) { |
|
| 396 | 396 | return \method_exists($this, $method); |
| 397 | 397 | })); |
| 398 | 398 | |
| 399 | 399 | // Otherwise, ensure the property actually exists. |
| 400 | - if (! $method && ! \property_exists($this, $key)) { |
|
| 400 | + if (!$method && !\property_exists($this, $key)) { |
|
| 401 | 401 | throw new \RuntimeException(\sprintf('Unknown property: %s', $key)); |
| 402 | 402 | } |
| 403 | 403 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | public function offsetSet($key, $value): void // phpcs:ignore |
| 414 | 414 | { |
| 415 | 415 | // Immediately return if key or value isn't valid. |
| 416 | - if (! \property_exists($this, $key) || ! isset($value) || $value === '') { |
|
| 416 | + if (!\property_exists($this, $key) || !isset($value) || $value === '') { |
|
| 417 | 417 | return; |
| 418 | 418 | } |
| 419 | 419 | |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | { |
| 442 | 442 | $array = []; |
| 443 | 443 | foreach (\get_object_vars($this) as $key => $value) { |
| 444 | - if (! isset($value)) { |
|
| 444 | + if (!isset($value)) { |
|
| 445 | 445 | continue; |
| 446 | 446 | } |
| 447 | 447 | |