From f930ca794e2518b06a8b8d2c13228d60ee6fc67f Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Wed, 14 Jul 2021 13:37:18 +0200 Subject: [PATCH] Add a list of blacklisted tags --- src/NodaBlacklistedTerms.php | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/NodaBlacklistedTerms.php diff --git a/src/NodaBlacklistedTerms.php b/src/NodaBlacklistedTerms.php new file mode 100644 index 0000000..57576a9 --- /dev/null +++ b/src/NodaBlacklistedTerms.php @@ -0,0 +1,49 @@ + + */ +declare(strict_types = 1); + +/** + * Contains lists of disallowed terms by language. + */ +final class NodaBlacklistedTerms { + /** + * A blacklist of disallowed tags. All entries are listed in full lowercase. + */ + const TAG_BLACKLIST = [ + 'de' => [ + 'sonstige', + 'sonst.', + 'sonst', + 'andere', + 'weiteres', + ] + ]; + + /** + * Checks if an tag name is blacklisted. + * + * @param string $lang Input language. + * @param string $name Input name to check. + * + * @return boolean + */ + public static function tagIsInBlacklist(string $lang, string $name):bool { + + $toCheck = \strtolower($name); + + if (!isset(self::TAG_BLACKLIST[$lang])) { + return false; + } + + if (\in_array($toCheck, self::TAG_BLACKLIST[$lang], true)) { + return true; + } + + return false; + + } +}