From 43d8c408298966ee9211167d5f31abf175720481 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sat, 25 May 2024 00:26:02 +0200 Subject: [PATCH] Add new class for a concordance list for source types --- src/MDConcSourceTypes.php | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/MDConcSourceTypes.php diff --git a/src/MDConcSourceTypes.php b/src/MDConcSourceTypes.php new file mode 100644 index 0000000..c78f94c --- /dev/null +++ b/src/MDConcSourceTypes.php @@ -0,0 +1,41 @@ + + */ +declare(strict_types = 1); + +/** + * Provides a list for finding the source type for an input. + */ +final class MDConcSourceTypes implements MDImporterConcordanceListInterface { + + private const SOURCE_TYPES = [ + + // Book / default + "buch" => "book", + "literatur" => "book", + + ]; + + /** + * 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::SOURCE_TYPES[$input])) { + return self::SOURCE_TYPES[$input]; + } + if (isset(self::SOURCE_TYPES[strtolower($input)])) { + return self::SOURCE_TYPES[strtolower($input)]; + } + + throw new MDImporterMissingConcordance("Unknown source type: " . $input); + + } +}