@@ 34-47 (lines=14) @@ | ||
31 | * @throws \Unicodeveloper\Emoji\Exceptions\IsNull |
|
32 | * @throws \Unicodeveloper\Emoji\Exceptions\UnknownUnicode |
|
33 | */ |
|
34 | public function findByAlias($emojiName = null) : string |
|
35 | { |
|
36 | if (is_null($emojiName)) { |
|
37 | throw IsNull::create("Please provide the name of the emoji you are looking for"); |
|
38 | } |
|
39 | ||
40 | $emoji = strtolower($emojiName); |
|
41 | ||
42 | if (! array_key_exists($emoji, $this->getEmojis())) { |
|
43 | throw UnknownEmoji::create($emoji); |
|
44 | } |
|
45 | ||
46 | return $this->getEmojis()[$emoji]; |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * Get the emoji by passing the commonly used emoji name |
|
@@ 67-80 (lines=14) @@ | ||
64 | * @throws \Unicodeveloper\Emoji\Exceptions\IsNull |
|
65 | * @throws \Unicodeveloper\Emoji\Exceptions\UnknownUnicode |
|
66 | */ |
|
67 | public function findByUnicode($unicode = null) : string |
|
68 | { |
|
69 | if (is_null($unicode)) { |
|
70 | throw IsNull::create("Please provide a valid UTF-8 Unicode value"); |
|
71 | } |
|
72 | ||
73 | $emojis = array_flip($this->getEmojis()); |
|
74 | ||
75 | if (! array_key_exists($unicode, $emojis)) { |
|
76 | throw UnknownUnicode::create($unicode); |
|
77 | } |
|
78 | ||
79 | return $emojis[$unicode]; |
|
80 | } |
|
81 | ||
82 | /** |
|
83 | * Ensure that a proper exception is thrown for methods that do not exist |