Add a list of blacklisted tags

This commit is contained in:
Joshua Ramon Enslin 2021-07-14 13:37:18 +02:00
parent 0fa759c604
commit f930ca794e
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -0,0 +1,49 @@
<?PHP
/**
* Contains a class of blacklists for unwanted terms.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
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;
}
}