Skip to content

Commit 4d56f7a

Browse files
fix(emoji): 🙆‍♀️ 💪 Add appropriate error handling for getting the alias of a unicode value
1 parent bd2d3af commit 4d56f7a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Emoji.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function findByAlias($emojiName = null)
3737

3838
public function findByName($emojiName = null)
3939
{
40-
$this->findByAlias($emojiName);
40+
return $this->findByAlias($emojiName);
4141
}
4242

4343
public function findByUnicode($unicode = null)
@@ -46,9 +46,13 @@ public function findByUnicode($unicode = null)
4646
throw new \Exception("Please provide a valid UTF-8 Unicode value");
4747
}
4848

49-
$emoji = array_flip($this->getEmojis());
49+
$emojis = array_flip($this->getEmojis());
5050

51-
return $emoji[$unicode];
51+
if (! array_key_exists($unicode, $emojis)) {
52+
throw new \Exception("Emoji Not Found, Man. Please provide a valid UTF-8 Unicode value");
53+
}
54+
55+
return $emojis[$unicode];
5256
}
5357

5458
}

0 commit comments

Comments
 (0)