MDNodaHelpers/src/NodaBlacklistedTerms.php

65 lines
1.3 KiB
PHP
Raw Normal View History

2021-07-14 13:37:18 +02:00
<?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' => [
'andere',
'anderes',
'sonst',
'sonst.',
'sonstige',
'versch.',
'verschiedenes',
'unbekannt',
'weitere',
2021-07-14 13:37:18 +02:00
'weiteres',
],
'en' => [
'other',
'others',
'unknown',
'various',
],
'hu' => [
'ism.',
'ismeretlen',
],
2021-07-14 13:37:18 +02:00
];
/**
* 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;
}
}