1 | <?php |
||
7 | class Emojify |
||
8 | { |
||
9 | /** |
||
10 | * The path to the file containing the emoji map. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | const EMOJI_MAP_FILE = '/../Storage/emoji.json'; |
||
15 | |||
16 | /** |
||
17 | * The array mapping words to emoji. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $emojiMap; |
||
22 | |||
23 | /** |
||
24 | * The array mapping emoji back to words. |
||
25 | * |
||
26 | * @var [type] |
||
27 | */ |
||
28 | protected $wordMap; |
||
29 | |||
30 | /** |
||
31 | * Emojify constructor. |
||
32 | * |
||
33 | * @param null $emojiMapFile |
||
34 | */ |
||
35 | 82 | public function __construct($emojiMapFile = null) |
|
49 | |||
50 | /** |
||
51 | * Translate Word to Emoji |
||
52 | * |
||
53 | * @param $text |
||
54 | * |
||
55 | * @return mixed |
||
56 | */ |
||
57 | 6 | public function toEmoji($text) |
|
61 | |||
62 | /** |
||
63 | * Alias of toEmoji() |
||
64 | * |
||
65 | * @param $text |
||
66 | * |
||
67 | * @return mixed |
||
68 | */ |
||
69 | public static function text($text) |
||
73 | |||
74 | /** |
||
75 | * Translate Emoji to Word |
||
76 | * |
||
77 | * @param $text |
||
78 | * |
||
79 | * @return mixed |
||
80 | */ |
||
81 | 10 | public function toWord($text) |
|
85 | |||
86 | /** |
||
87 | * Alias of toWord() |
||
88 | * |
||
89 | * @param $text |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | 8 | public static function translate($text) |
|
97 | |||
98 | /** |
||
99 | * Replace |
||
100 | * |
||
101 | * @param $line |
||
102 | * @param $replace |
||
103 | * @param string $startDelimiter |
||
104 | * |
||
105 | * @return mixed |
||
106 | */ |
||
107 | protected function replace($line, $replace, $startDelimiter = ':') |
||
119 | } |
||
120 |