Passed
Push — master ( b2d1c8...8355f9 )
by Roeland
13:35
created
apps/user_status/lib/Service/EmojiService.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -34,68 +34,68 @@
 block discarded – undo
34 34
  */
35 35
 class EmojiService {
36 36
 
37
-	/** @var IDBConnection */
38
-	private $db;
39
-
40
-	/**
41
-	 * EmojiService constructor.
42
-	 *
43
-	 * @param IDBConnection $db
44
-	 */
45
-	public function __construct(IDBConnection $db) {
46
-		$this->db = $db;
47
-	}
48
-
49
-	/**
50
-	 * @return bool
51
-	 */
52
-	public function doesPlatformSupportEmoji(): bool {
53
-		return $this->db->supports4ByteText() &&
54
-			\class_exists(\IntlBreakIterator::class);
55
-	}
56
-
57
-	/**
58
-	 * @param string $emoji
59
-	 * @return bool
60
-	 */
61
-	public function isValidEmoji(string $emoji): bool {
62
-		$intlBreakIterator = \IntlBreakIterator::createCharacterInstance();
63
-		$intlBreakIterator->setText($emoji);
64
-
65
-		$characterCount = 0;
66
-		while ($intlBreakIterator->next() !== \IntlBreakIterator::DONE) {
67
-			$characterCount++;
68
-		}
69
-
70
-		if ($characterCount !== 1) {
71
-			return false;
72
-		}
73
-
74
-		$codePointIterator = \IntlBreakIterator::createCodePointInstance();
75
-		$codePointIterator->setText($emoji);
76
-
77
-		foreach ($codePointIterator->getPartsIterator() as $codePoint) {
78
-			$codePointType = \IntlChar::charType($codePoint);
79
-
80
-			// If the current code-point is an emoji or a modifier (like a skin-tone)
81
-			// just continue and check the next character
82
-			if ($codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL ||
83
-				$codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_LETTER ||
84
-				$codePointType === \IntlChar::CHAR_CATEGORY_OTHER_SYMBOL ||
85
-				$codePointType === \IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES) {
86
-				continue;
87
-			}
88
-
89
-			// If it's neither a modifier nor an emoji, we only allow
90
-			// a zero-width-joiner or a variation selector 16
91
-			$codePointValue = \IntlChar::ord($codePoint);
92
-			if ($codePointValue === 8205 || $codePointValue === 65039) {
93
-				continue;
94
-			}
95
-
96
-			return false;
97
-		}
98
-
99
-		return true;
100
-	}
37
+    /** @var IDBConnection */
38
+    private $db;
39
+
40
+    /**
41
+     * EmojiService constructor.
42
+     *
43
+     * @param IDBConnection $db
44
+     */
45
+    public function __construct(IDBConnection $db) {
46
+        $this->db = $db;
47
+    }
48
+
49
+    /**
50
+     * @return bool
51
+     */
52
+    public function doesPlatformSupportEmoji(): bool {
53
+        return $this->db->supports4ByteText() &&
54
+            \class_exists(\IntlBreakIterator::class);
55
+    }
56
+
57
+    /**
58
+     * @param string $emoji
59
+     * @return bool
60
+     */
61
+    public function isValidEmoji(string $emoji): bool {
62
+        $intlBreakIterator = \IntlBreakIterator::createCharacterInstance();
63
+        $intlBreakIterator->setText($emoji);
64
+
65
+        $characterCount = 0;
66
+        while ($intlBreakIterator->next() !== \IntlBreakIterator::DONE) {
67
+            $characterCount++;
68
+        }
69
+
70
+        if ($characterCount !== 1) {
71
+            return false;
72
+        }
73
+
74
+        $codePointIterator = \IntlBreakIterator::createCodePointInstance();
75
+        $codePointIterator->setText($emoji);
76
+
77
+        foreach ($codePointIterator->getPartsIterator() as $codePoint) {
78
+            $codePointType = \IntlChar::charType($codePoint);
79
+
80
+            // If the current code-point is an emoji or a modifier (like a skin-tone)
81
+            // just continue and check the next character
82
+            if ($codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL ||
83
+                $codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_LETTER ||
84
+                $codePointType === \IntlChar::CHAR_CATEGORY_OTHER_SYMBOL ||
85
+                $codePointType === \IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES) {
86
+                continue;
87
+            }
88
+
89
+            // If it's neither a modifier nor an emoji, we only allow
90
+            // a zero-width-joiner or a variation selector 16
91
+            $codePointValue = \IntlChar::ord($codePoint);
92
+            if ($codePointValue === 8205 || $codePointValue === 65039) {
93
+                continue;
94
+            }
95
+
96
+            return false;
97
+        }
98
+
99
+        return true;
100
+    }
101 101
 }
Please login to merge, or discard this patch.