Skip to content

Commit fc9aeb4

Browse files
feat(emoji): 👿 💔 Add UnknownUnicode Exception
1 parent 056c73a commit fc9aeb4

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, UnknownEmoji };
5+
use Unicodeveloper\Emoji\Exceptions\{ UnknownMethod, UnknownEmoji, UnknownUnicode };
66

77
class Emoji {
88

@@ -51,7 +51,7 @@ public function findByUnicode($unicode = null)
5151
$emojis = array_flip($this->getEmojis());
5252

5353
if (! array_key_exists($unicode, $emojis)) {
54-
throw new \Exception("Emoji Not Found, Man. Please provide a valid UTF-8 Unicode value");
54+
throw UnknownUnicode::create($unicode);
5555
}
5656

5757
return $emojis[$unicode];

src/Exceptions/UnknownUnicode.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 UnknownUnicode extends Exception
8+
{
9+
public static function create($unicode) : UnknownUnicode
10+
{
11+
return new static("Unicode {$unicode} Not Found, Man. Please provide a valid UTF-8 Unicode value");
12+
}
13+
}

0 commit comments

Comments
 (0)