Move "isType" to Tag.php

This commit is contained in:
Michael 2020-05-01 12:39:41 +00:00
parent ac2957c4dd
commit 029a379060
3 changed files with 24 additions and 25 deletions

View file

@ -471,4 +471,23 @@ class Tag
return $tags ?: [];
}
/**
* 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);
}
}