| Total Complexity | 10 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class Emoji { |
||
| 6 | |||
| 7 | private static $chmap = []; |
||
| 8 | private static $inverse_char_map = []; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * Generate the char map |
||
| 12 | */ |
||
| 13 | private static function generateMap() { |
||
| 14 | if ( empty( self::$chmap ) ) { |
||
| 15 | self::$chmap = include_once 'chmap.php'; |
||
| 16 | } |
||
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Generate the inverse char map |
||
| 21 | */ |
||
| 22 | private static function generateReverseMap() { |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param $str |
||
| 32 | * |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | public static function toEntity( $str ) { |
||
| 36 | self::generateMap(); |
||
| 37 | $letters = preg_split( '//u', $str, null, PREG_SPLIT_NO_EMPTY ); |
||
| 38 | |||
| 39 | foreach ( $letters as $letter ) { |
||
| 40 | if ( isset ( self::$chmap[ $letter ] ) ) { |
||
| 41 | $str = str_replace( $letter, self::$chmap[ $letter ], $str ); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | return $str; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param $str |
||
| 50 | * |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | public static function toEmoji( $str ) { |
||
| 64 | } |
||
| 65 | |||
| 66 | } |