@@ -30,68 +30,68 @@ |
||
30 | 30 | use OCP\IEmojiHelper; |
31 | 31 | |
32 | 32 | class EmojiHelper implements IEmojiHelper { |
33 | - private IDBConnection $db; |
|
33 | + private IDBConnection $db; |
|
34 | 34 | |
35 | - public function __construct(IDBConnection $db) { |
|
36 | - $this->db = $db; |
|
37 | - } |
|
35 | + public function __construct(IDBConnection $db) { |
|
36 | + $this->db = $db; |
|
37 | + } |
|
38 | 38 | |
39 | - public function doesPlatformSupportEmoji(): bool { |
|
40 | - return $this->db->supports4ByteText() && |
|
41 | - \class_exists(\IntlBreakIterator::class); |
|
42 | - } |
|
39 | + public function doesPlatformSupportEmoji(): bool { |
|
40 | + return $this->db->supports4ByteText() && |
|
41 | + \class_exists(\IntlBreakIterator::class); |
|
42 | + } |
|
43 | 43 | |
44 | - public function isValidSingleEmoji(string $emoji): bool { |
|
45 | - $intlBreakIterator = \IntlBreakIterator::createCharacterInstance(); |
|
46 | - $intlBreakIterator->setText($emoji); |
|
44 | + public function isValidSingleEmoji(string $emoji): bool { |
|
45 | + $intlBreakIterator = \IntlBreakIterator::createCharacterInstance(); |
|
46 | + $intlBreakIterator->setText($emoji); |
|
47 | 47 | |
48 | - $characterCount = 0; |
|
49 | - while ($intlBreakIterator->next() !== \IntlBreakIterator::DONE) { |
|
50 | - $characterCount++; |
|
51 | - } |
|
48 | + $characterCount = 0; |
|
49 | + while ($intlBreakIterator->next() !== \IntlBreakIterator::DONE) { |
|
50 | + $characterCount++; |
|
51 | + } |
|
52 | 52 | |
53 | - if ($characterCount !== 1) { |
|
54 | - return false; |
|
55 | - } |
|
53 | + if ($characterCount !== 1) { |
|
54 | + return false; |
|
55 | + } |
|
56 | 56 | |
57 | - $codePointIterator = \IntlBreakIterator::createCodePointInstance(); |
|
58 | - $codePointIterator->setText($emoji); |
|
57 | + $codePointIterator = \IntlBreakIterator::createCodePointInstance(); |
|
58 | + $codePointIterator->setText($emoji); |
|
59 | 59 | |
60 | - foreach ($codePointIterator->getPartsIterator() as $codePoint) { |
|
61 | - $codePointType = \IntlChar::charType($codePoint); |
|
60 | + foreach ($codePointIterator->getPartsIterator() as $codePoint) { |
|
61 | + $codePointType = \IntlChar::charType($codePoint); |
|
62 | 62 | |
63 | - // Unicode chars need 2 or more chars |
|
64 | - // The characterCount before this loop already validate if is a single emoji |
|
65 | - // This condition is to don't continue if non emoji chars |
|
66 | - if (strlen($emoji) >= 2) { |
|
67 | - // If the current code-point is an emoji or a modifier (like a skin-tone) |
|
68 | - // just continue and check the next character |
|
69 | - if ($codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL || |
|
70 | - $codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_LETTER || |
|
71 | - $codePointType === \IntlChar::CHAR_CATEGORY_OTHER_SYMBOL || |
|
72 | - $codePointType === \IntlChar::CHAR_CATEGORY_FORMAT_CHAR || // i.e. |
@@ -69,13 +69,13 @@ |
||
69 | 69 | if ($codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL || |
70 | 70 | $codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_LETTER || |
71 | 71 | $codePointType === \IntlChar::CHAR_CATEGORY_OTHER_SYMBOL || |
72 | - $codePointType === \IntlChar::CHAR_CATEGORY_FORMAT_CHAR || // i.e. |