Skip to content

Commit 056c73a

Browse files
feat(emoji): 😿 😥 Add UnknownEmoji Exception
1 parent 0d6dbba commit 056c73a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Emoji.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Unicodeveloper\Emoji;
44

5-
use Unicodeveloper\Emoji\Exceptions\UnknownMethod;
5+
use Unicodeveloper\Emoji\Exceptions\{ UnknownMethod, UnknownEmoji };
66

77
class Emoji {
88

@@ -31,7 +31,7 @@ public function findByAlias($emojiName = null)
3131
$emoji = strtolower($emojiName);
3232

3333
if (! array_key_exists($emoji, $this->getEmojis())) {
34-
throw new \Exception("Emoji Not Found, Man. Check your spelling and try again");
34+
throw UnknownEmoji::create($emoji);
3535
}
3636

3737
return $this->getEmojis()[$emoji];

src/Exceptions/UnknownEmoji.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Unicodeveloper\Emoji\Exceptions;
4+
5+
use Exception;
6+
7+
class UnknownEmoji extends Exception
8+
{
9+
public static function create($emoji) : UnknownEmoji
10+
{
11+
return new static("Emoji {$emoji} Not Found, Man. Check your spelling and try again");
12+
}
13+
}

0 commit comments

Comments
 (0)