Add class MDConcObjectTagRelTypes for mapping strings to object-tag

relation types
This commit is contained in:
Joshua Ramon Enslin 2024-11-14 15:30:25 +01:00
parent f08ea28622
commit c106318d38
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -0,0 +1,49 @@
<?PHP
/**
* Constains lists for categorizing links between objects and tags.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Constains lists for categorizing links between objects and tags.
*/
final class MDConcObjectTagRelTypes implements MDImporterConcordanceListInterface {
private const RELATION_TYPE_NAMES = [
'' => 'tag',
'tag' => 'tag',
"motive" => "article",
"motiv" => "article",
"display" => "display_subject",
"material" => "material",
"technique" => "technique",
"technik" => "technique",
];
/**
* Require a function for getting the concordance target.
*
* @param string $input Input string.
*
* @return string
*/
public static function getConcordanceTarget(string $input):string {
if (isset(self::RELATION_TYPE_NAMES[$input])) {
return self::RELATION_TYPE_NAMES[$input];
}
if (isset(self::RELATION_TYPE_NAMES[strtolower($input)])) {
return self::RELATION_TYPE_NAMES[strtolower($input)];
}
throw new MDImporterMissingConcordance("Unknown object-tag relationship type: " . $input);
}
}