From c106318d38ab3821ce8ee787d5ee1098a31830b7 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 14 Nov 2024 15:30:25 +0100 Subject: [PATCH] Add class MDConcObjectTagRelTypes for mapping strings to object-tag relation types --- src/MDConcObjectTagRelTypes.php | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/MDConcObjectTagRelTypes.php diff --git a/src/MDConcObjectTagRelTypes.php b/src/MDConcObjectTagRelTypes.php new file mode 100644 index 0000000..9da1e1b --- /dev/null +++ b/src/MDConcObjectTagRelTypes.php @@ -0,0 +1,49 @@ + + */ +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); + + } +}