+
+ /**
+ * Delete tags of the specific type(s) from an item
+ *
+ * @param int $item_id
+ * @param int|array $type
+ * @throws \Exception
+ */
+ public static function deleteByItemId($item_id, $type = [self::HASHTAG, self::MENTION, self::IMPLICIT_MENTION])
+ {
+ if (empty($item_id)) {
+ return;
+ }
+
+ // Clean up all tags
+ DBA::delete('term', ['otype' => self::OBJECT_TYPE_POST, 'oid' => $item_id, 'type' => $type]);
+ }
+
+ /**
+ * Check if the provided tag is of one of the provided term types.
+ *
+ * @param string $tag
+ * @param int ...$types
+ * @return bool
+ */
+ public static function isType($tag, ...$types)
+ {
+ $tag_chars = [];
+ foreach ($types as $type) {
+ if (array_key_exists($type, self::TAG_CHARACTER)) {
+ $tag_chars[] = self::TAG_CHARACTER[$type];
+ }
+ }
+
+ return Strings::startsWith($tag, $tag_chars);
+ }