Add new class for a concordance list for source types

This commit is contained in:
Joshua Ramon Enslin 2024-05-25 00:26:02 +02:00
parent 2c100f497b
commit 43d8c40829
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

41
src/MDConcSourceTypes.php Normal file
View File

@ -0,0 +1,41 @@
<?PHP
/**
* Constains lists for categorizing source types.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
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);
}
}