@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * Generate the char map |
| 12 | 12 | */ |
| 13 | 13 | private static function generateMap() { |
| 14 | - if ( empty( self::$chmap ) ) { |
|
| 14 | + if (empty(self::$chmap)) { |
|
| 15 | 15 | self::$chmap = include_once 'chmap.php'; |
| 16 | 16 | } |
| 17 | 17 | } |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | private static function generateReverseMap() { |
| 23 | 23 | self::generateMap(); |
| 24 | 24 | |
| 25 | - if ( empty( self::$inverse_char_map ) ) { |
|
| 26 | - self::$inverse_char_map = array_flip( self::$chmap ); |
|
| 25 | + if (empty(self::$inverse_char_map)) { |
|
| 26 | + self::$inverse_char_map = array_flip(self::$chmap); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return string |
| 34 | 34 | */ |
| 35 | - public static function toEntity( $str ) { |
|
| 35 | + public static function toEntity($str) { |
|
| 36 | 36 | self::generateMap(); |
| 37 | - $letters = preg_split( '//u', $str, null, PREG_SPLIT_NO_EMPTY ); |
|
| 37 | + $letters = preg_split('//u', $str, null, PREG_SPLIT_NO_EMPTY); |
|
| 38 | 38 | |
| 39 | - foreach ( $letters as $letter ) { |
|
| 40 | - if ( isset ( self::$chmap[ $letter ] ) ) { |
|
| 41 | - $str = str_replace( $letter, self::$chmap[ $letter ], $str ); |
|
| 39 | + foreach ($letters as $letter) { |
|
| 40 | + if (isset (self::$chmap[$letter])) { |
|
| 41 | + $str = str_replace($letter, self::$chmap[$letter], $str); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | - public static function toEmoji( $str ) { |
|
| 53 | + public static function toEmoji($str) { |
|
| 54 | 54 | self::generateReverseMap(); |
| 55 | - preg_match_all( '/&#[0-9a-fA-F]+;/', $str, $emoji_entity_list, PREG_PATTERN_ORDER ); |
|
| 55 | + preg_match_all('/&#[0-9a-fA-F]+;/', $str, $emoji_entity_list, PREG_PATTERN_ORDER); |
|
| 56 | 56 | |
| 57 | - foreach ( $emoji_entity_list[ 0 ] as $emoji_entity ) { |
|
| 58 | - if ( array_key_exists( $emoji_entity, self::$inverse_char_map ) ) { |
|
| 59 | - $str = str_replace( $emoji_entity, self::$inverse_char_map[ $emoji_entity ], $str ); |
|
| 57 | + foreach ($emoji_entity_list[0] as $emoji_entity) { |
|
| 58 | + if (array_key_exists($emoji_entity, self::$inverse_char_map)) { |
|
| 59 | + $str = str_replace($emoji_entity, self::$inverse_char_map[$emoji_entity], $str); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | protected function configure() { |
| 13 | 13 | $this |
| 14 | - ->setName( 'emoji:update' ) |
|
| 15 | - ->setDescription( 'Update the emoji static map.' ) |
|
| 16 | - ->setHelp( "Update the emoji static map with emoji-api.com API." ); |
|
| 14 | + ->setName('emoji:update') |
|
| 15 | + ->setDescription('Update the emoji static map.') |
|
| 16 | + ->setHelp("Update the emoji static map with emoji-api.com API."); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | protected function execute(InputInterface $input, OutputInterface $output): int |
| 25 | 25 | { |
| 26 | 26 | // SymfonyStyle |
| 27 | - $io = new SymfonyStyle( $input, $output ); |
|
| 27 | + $io = new SymfonyStyle($input, $output); |
|
| 28 | 28 | $io->title('Update the emoji static map with emoji-api.com API'); |
| 29 | 29 | |
| 30 | 30 | $apiKey = parse_ini_file(__DIR__.'/../../config/credentials.ini'); |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | $updates = 0; |
| 37 | 37 | $skipped = 0; |
| 38 | 38 | |
| 39 | - foreach ($emojis as $emoji){ |
|
| 39 | + foreach ($emojis as $emoji) { |
|
| 40 | 40 | $this->importEmoji($emoji, $io, $i, $updates, $skipped); |
| 41 | 41 | |
| 42 | - if(isset($emoji->variants) and is_array($emoji->variants)){ |
|
| 43 | - foreach ($emoji->variants as $variant){ |
|
| 42 | + if (isset($emoji->variants) and is_array($emoji->variants)) { |
|
| 43 | + foreach ($emoji->variants as $variant) { |
|
| 44 | 44 | $this->importEmoji($variant, $io, $i, $updates, $skipped); |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $htmlEntities = $this->convertEmojiToHtmlEntities($emoji->character); |
| 68 | 68 | |
| 69 | - $chmapFile = __DIR__ . '/../chmap.php'; |
|
| 69 | + $chmapFile = __DIR__.'/../chmap.php'; |
|
| 70 | 70 | $chmap = include $chmapFile; |
| 71 | 71 | $inverseChmap = array_flip($chmap); |
| 72 | 72 | |
| 73 | - foreach ($htmlEntities as $character => $htmlEntity){ |
|
| 74 | - if(strlen($htmlEntity) >= 8){ |
|
| 75 | - if(!isset($inverseChmap[$htmlEntity])){ |
|
| 73 | + foreach ($htmlEntities as $character => $htmlEntity) { |
|
| 74 | + if (strlen($htmlEntity) >= 8) { |
|
| 75 | + if (!isset($inverseChmap[$htmlEntity])) { |
|
| 76 | 76 | $outcome = 'UPDATED'; |
| 77 | 77 | $outcomeColor = 'cyan'; |
| 78 | 78 | $updates++; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $chmapArray .= PHP_EOL; |
| 123 | 123 | $chmapArray .= " */"; |
| 124 | 124 | $chmapArray .= PHP_EOL; |
| 125 | - $chmapArray .= "return ". var_export($chmap, true) .";"; |
|
| 125 | + $chmapArray .= "return ".var_export($chmap, true).";"; |
|
| 126 | 126 | $chmapArray .= PHP_EOL; |
| 127 | 127 | |
| 128 | 128 | return $chmapArray; |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function convertEmojiToHtmlEntities($emoji) |
| 136 | 136 | { |
| 137 | - $letters = preg_split( '//u', $emoji, null, PREG_SPLIT_NO_EMPTY ); |
|
| 137 | + $letters = preg_split('//u', $emoji, null, PREG_SPLIT_NO_EMPTY); |
|
| 138 | 138 | $entities = []; |
| 139 | 139 | |
| 140 | - foreach ( $letters as $letter ) { |
|
| 140 | + foreach ($letters as $letter) { |
|
| 141 | 141 | |
| 142 | 142 | $utf32 = mb_convert_encoding($letter, 'UTF-32', 'UTF-8'); |
| 143 | 143 | $hex4 = bin2hex($utf32); |