Use function getConcordanceTarget() over direct array access

This commit is contained in:
2023-05-14 12:11:23 +02:00
parent c6dca5493d
commit 78fa0c4ce9
18 changed files with 328 additions and 33 deletions

View File

@ -9,7 +9,7 @@ declare(strict_types = 1);
/**
* Provides a list for finding the respective event type for a given place role.
*/
final class MDConcPlace {
final class MDConcPlace implements MDImporterConcordanceListInterface {
/**
* Substrings of an place name listed as a key in this array will be replaced
@ -23,7 +23,7 @@ final class MDConcPlace {
"Unknown" => "",
];
const PLACE_ROLES_TO_EVENT_TYPE = [
private const PLACE_ROLES_TO_EVENT_TYPE = [
// 22: Related place
'' => 22,
@ -105,4 +105,20 @@ final class MDConcPlace {
];
/**
* Require a function for getting the concordance target.
*
* @param string $input Input string.
*
* @return integer
*/
public static function getConcordanceTarget(string $input):int {
if (!isset(self::PLACE_ROLES_TO_EVENT_TYPE[$input])) {
throw new MDImporterMissingConcordance("Unknown place type: " . $input);
}
return self::PLACE_ROLES_TO_EVENT_TYPE[$input];
}
}