Add blacklist for invalid damage types
This commit is contained in:
parent
881a3d6c9c
commit
016245722a
18
exceptions/MDImporterBlacklistedConcordanceTerm.php
Normal file
18
exceptions/MDImporterBlacklistedConcordanceTerm.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?PHP
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Exception thrown in case a requested concordance term is blacklisted.
|
||||
*/
|
||||
final class MDImporterBlacklistedConcordanceTerm extends Exception {
|
||||
/**
|
||||
* Error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function errorMessage() {
|
||||
//error message
|
||||
return 'Blacklisted term requested for concordance list.';
|
||||
|
||||
}
|
||||
}
|
@ -18,6 +18,10 @@ final class MDConcDamageTypes implements MDImporterConcordanceListInterface {
|
||||
"Desiccation" => MDObjectDamageType::desiccation,
|
||||
];
|
||||
|
||||
private const DAMAGE_TYPES_BLACKLIST = [
|
||||
'keine',
|
||||
];
|
||||
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
@ -28,6 +32,11 @@ final class MDConcDamageTypes implements MDImporterConcordanceListInterface {
|
||||
public static function getConcordanceTarget(string $input):MDObjectDamageType {
|
||||
|
||||
if (!isset(self::DAMAGE_TYPES[$input])) {
|
||||
|
||||
if (in_array($input, self::DAMAGE_TYPES_BLACKLIST, true)) {
|
||||
throw new MDImporterBlacklistedConcordanceTerm("Invalid damage type: " . $input);
|
||||
}
|
||||
|
||||
throw new MDImporterMissingConcordance("Unknown damage type: " . $input);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user