@@ -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( string $str ): string { |
|
| 35 | + public static function toEntity(string $str): string { |
|
| 36 | 36 | self::generateMap(); |
| 37 | - $letters = preg_split( '//u', $str, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 37 | + $letters = preg_split('//u', $str, -1, 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( string $str ): string { |
|
| 53 | + public static function toEmoji(string $str): string { |
|
| 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 | |