Add new class for a concordance list for source types
This commit is contained in:
parent
2c100f497b
commit
43d8c40829
41
src/MDConcSourceTypes.php
Normal file
41
src/MDConcSourceTypes.php
Normal 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);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user