Use function getConcordanceTarget() over direct array access
This commit is contained in:
parent
c6dca5493d
commit
78fa0c4ce9
18
exceptions/MDImporterMissingConcordance.php
Normal file
18
exceptions/MDImporterMissingConcordance.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?PHP
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Exception thrown in case an update failed.
|
||||
*/
|
||||
final class MDImporterMissingConcordance extends Exception {
|
||||
/**
|
||||
* Error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function errorMessage() {
|
||||
//error message
|
||||
return 'No matching entry in concordance list.';
|
||||
|
||||
}
|
||||
}
|
21
interfaces/MDImporterConcordanceListInterface.php
Normal file
21
interfaces/MDImporterConcordanceListInterface.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Describes a concordance list for importer concordance lists.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Describes a concordance list for importer concordance lists.
|
||||
*/
|
||||
interface MDImporterConcordanceListInterface {
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
* @param string $input Input string.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getConcordanceTarget(string $input);
|
||||
}
|
|
@ -9,7 +9,7 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides a list for finding the respective event type for a given actor role.
|
||||
*/
|
||||
final class MDConcActor {
|
||||
final class MDConcActor implements MDImporterConcordanceListInterface {
|
||||
|
||||
/**
|
||||
* Substrings of an actor name listed as a key in this array will be replaced
|
||||
|
@ -22,7 +22,7 @@ final class MDConcActor {
|
|||
"()" => "",
|
||||
];
|
||||
|
||||
const ACTOR_ROLES_TO_EVENT_TYPE = [
|
||||
private const ACTOR_ROLES_TO_EVENT_TYPE = [
|
||||
|
||||
// 1: Created
|
||||
"Aktionskünstler" => 1,
|
||||
|
@ -866,4 +866,20 @@ final class MDConcActor {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
* @param string $input Input string.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getConcordanceTarget(string $input):int {
|
||||
|
||||
if (!isset(self::ACTOR_ROLES_TO_EVENT_TYPE[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown actor role: " . $input);
|
||||
}
|
||||
|
||||
return self::ACTOR_ROLES_TO_EVENT_TYPE[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,26 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing misspelled check types.
|
||||
*/
|
||||
final class MDConcCheckTypes {
|
||||
final class MDConcCheckTypes implements MDImporterConcordanceListInterface {
|
||||
|
||||
const CHECK_TYPES = [
|
||||
private const CHECK_TYPES = [
|
||||
"Vollständigkeit" => MDObjectCheckType::completeness_check,
|
||||
];
|
||||
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
* @param string $input Input string.
|
||||
*
|
||||
* @return MDObjectCheckType
|
||||
*/
|
||||
public static function getConcordanceTarget(string $input):MDObjectCheckType {
|
||||
|
||||
if (!isset(self::CHECK_TYPES[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown check type: " . $input);
|
||||
}
|
||||
|
||||
return self::CHECK_TYPES[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing spelled out closer location types.
|
||||
*/
|
||||
final class MDConcCloserLocationTypes {
|
||||
final class MDConcCloserLocationTypes implements MDImporterConcordanceListInterface {
|
||||
|
||||
const LOCATION_TYPES_VERBOSE = [
|
||||
private const LOCATION_TYPES_VERBOSE = [
|
||||
|
||||
# Place of recording
|
||||
"" => "0",
|
||||
|
@ -33,4 +33,20 @@ final class MDConcCloserLocationTypes {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::LOCATION_TYPES_VERBOSE[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown location type: " . $input);
|
||||
}
|
||||
|
||||
return self::LOCATION_TYPES_VERBOSE[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing spelled out currencies.
|
||||
*/
|
||||
final class MDConcCurrencies {
|
||||
final class MDConcCurrencies implements MDImporterConcordanceListInterface {
|
||||
|
||||
const CURRENCIES_LIST = [
|
||||
private const CURRENCIES_LIST = [
|
||||
"^" => "",
|
||||
"-" => "",
|
||||
"x" => "",
|
||||
|
@ -48,4 +48,20 @@ final class MDConcCurrencies {
|
|||
"US dollar" => "us-USD",
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::CURRENCIES_LIST[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown currency: " . $input);
|
||||
}
|
||||
|
||||
return self::CURRENCIES_LIST[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,26 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing misspelled damage types.
|
||||
*/
|
||||
final class MDConcDamageTypes {
|
||||
final class MDConcDamageTypes implements MDImporterConcordanceListInterface {
|
||||
|
||||
const DAMAGE_TYPES = [
|
||||
private const DAMAGE_TYPES = [
|
||||
"breakage" => MDObjectDamageType::breakage,
|
||||
];
|
||||
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
* @param string $input Input string.
|
||||
*
|
||||
* @return MDObjectDamageType
|
||||
*/
|
||||
public static function getConcordanceTarget(string $input):MDObjectDamageType {
|
||||
|
||||
if (!isset(self::DAMAGE_TYPES[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown damage type: " . $input);
|
||||
}
|
||||
|
||||
return self::DAMAGE_TYPES[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing spelled out entry types.
|
||||
*/
|
||||
final class MDConcEntryTypes {
|
||||
final class MDConcEntryTypes implements MDImporterConcordanceListInterface {
|
||||
|
||||
const ENTRY_TYPES_VERBOSE = [
|
||||
private const ENTRY_TYPES_VERBOSE = [
|
||||
|
||||
// 0: No known entry type
|
||||
"" => "0",
|
||||
|
@ -197,4 +197,20 @@ final class MDConcEntryTypes {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::ENTRY_TYPES_VERBOSE[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown entry type: " . $input);
|
||||
}
|
||||
|
||||
return self::ENTRY_TYPES_VERBOSE[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides a list for finding the respective event type ID for a given event type name.
|
||||
*/
|
||||
final class MDConcEventTypes {
|
||||
final class MDConcEventTypes implements MDImporterConcordanceListInterface {
|
||||
|
||||
const EVENT_TYPE_NAMES_TO_ID = [
|
||||
private const EVENT_TYPE_NAMES_TO_ID = [
|
||||
|
||||
// 1: Created
|
||||
'Hergestellt' => 1,
|
||||
|
@ -74,4 +74,20 @@ final class MDConcEventTypes {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
* @param string $input Input string.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getConcordanceTarget(string $input):int {
|
||||
|
||||
if (!isset(self::EVENT_TYPE_NAMES_TO_ID[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown entry type: " . $input);
|
||||
}
|
||||
|
||||
return self::EVENT_TYPE_NAMES_TO_ID[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,27 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing spelled out languages.
|
||||
*/
|
||||
final class MDConcLanguages {
|
||||
final class MDConcLanguages implements MDImporterConcordanceListInterface {
|
||||
|
||||
const LANGUAGES_LIST = [
|
||||
private const LANGUAGES_LIST = [
|
||||
'Deutsch' => 'de',
|
||||
'German' => 'de',
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::LANGUAGES_LIST[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown language type: " . $input);
|
||||
}
|
||||
|
||||
return self::LANGUAGES_LIST[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing misspelled sizes.
|
||||
*/
|
||||
final class MDConcLengths {
|
||||
final class MDConcLengths implements MDImporterConcordanceListInterface {
|
||||
|
||||
const LENGTHS_LIST = [
|
||||
private const LENGTHS_LIST = [
|
||||
"cn" => "cm",
|
||||
",cm" => "cm",
|
||||
"5cm" => "cm",
|
||||
|
@ -21,4 +21,20 @@ final class MDConcLengths {
|
|||
"zoll" => "in",
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::LENGTHS_LIST[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown length type: " . $input);
|
||||
}
|
||||
|
||||
return self::LENGTHS_LIST[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing spelled out licenses.
|
||||
*/
|
||||
final class MDConcLicenses {
|
||||
final class MDConcLicenses implements MDImporterConcordanceListInterface {
|
||||
|
||||
const LICENSES_LIST = [
|
||||
private const LICENSES_LIST = [
|
||||
"CC 0" => "CC0",
|
||||
"CC_0" => "CC0",
|
||||
"CC0 1.0" => "CC0",
|
||||
|
@ -44,7 +44,7 @@ final class MDConcLicenses {
|
|||
"CC.BY-NC-SA" => "CC BY-NC-SA",
|
||||
"CC BY-NC-SA 3.0 AT" => "CC BY-NC-SA",
|
||||
"http://creativecommons.org/licenses/by-nc-sa/3.0/" => "CC BY-NC-SA",
|
||||
"https://creativecommons.org/licenses/by-nc-sa/4.0/" => "CC BY-NC-SA",
|
||||
"http://creativecommons.org/licenses/by-nc-sa/4.0/" => "CC BY-NC-SA",
|
||||
"https://creativecommons.org/licenses/by-nc-sa/4.0/" => "CC BY-NC-SA",
|
||||
"Namensnennung - Nicht kommerziell - Weitergabe unter gleichen Bedingungen 4.0 International (CC BY-NC-SA 4.0)" => "CC BY-NC-SA",
|
||||
|
||||
|
@ -69,4 +69,20 @@ final class MDConcLicenses {
|
|||
'PDM 1.0' => 'Public Domain Mark',
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::LICENSES_LIST[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown licence type: " . $input);
|
||||
}
|
||||
|
||||
return self::LICENSES_LIST[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides a list for finding the loan type for an input.
|
||||
*/
|
||||
final class MDConcLoanTypes {
|
||||
final class MDConcLoanTypes implements MDImporterConcordanceListInterface {
|
||||
|
||||
const LOAN_TYPES = [
|
||||
private const LOAN_TYPES = [
|
||||
|
||||
// Outgoing
|
||||
"ausgehend" => "outgoing",
|
||||
|
@ -21,4 +21,20 @@ final class MDConcLoanTypes {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::LOAN_TYPES[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown loan type: " . $input);
|
||||
}
|
||||
|
||||
return self::LOAN_TYPES[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing spelled out marking positions.
|
||||
*/
|
||||
final class MDConcMarkingPosition {
|
||||
final class MDConcMarkingPosition implements MDImporterConcordanceListInterface {
|
||||
|
||||
const MARKING_POSITIONS_VERBOSE = [
|
||||
private const MARKING_POSITIONS_VERBOSE = [
|
||||
|
||||
// Center
|
||||
"mittig" => "center",
|
||||
|
@ -294,4 +294,20 @@ final class MDConcMarkingPosition {
|
|||
"oberer Holzkasten" => "other",
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::MARKING_POSITIONS_VERBOSE[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown marking position: " . $input);
|
||||
}
|
||||
|
||||
return self::MARKING_POSITIONS_VERBOSE[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides lists for categorizing spelled out marking types.
|
||||
*/
|
||||
final class MDConcMarkingType {
|
||||
final class MDConcMarkingType implements MDImporterConcordanceListInterface {
|
||||
|
||||
const MARKING_TYPES_VERBOSE = [
|
||||
private const MARKING_TYPES_VERBOSE = [
|
||||
|
||||
// Default: Handwritten
|
||||
"x" => "handwritten",
|
||||
|
@ -318,4 +318,20 @@ final class MDConcMarkingType {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::MARKING_TYPES_VERBOSE[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown marking type: " . $input);
|
||||
}
|
||||
|
||||
return self::MARKING_TYPES_VERBOSE[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides a list for finding the respective event type for a given place role.
|
||||
*/
|
||||
final class MDConcPlace {
|
||||
final class MDConcPlace implements MDImporterConcordanceListInterface {
|
||||
|
||||
/**
|
||||
* Substrings of an place name listed as a key in this array will be replaced
|
||||
|
@ -23,7 +23,7 @@ final class MDConcPlace {
|
|||
"Unknown" => "",
|
||||
];
|
||||
|
||||
const PLACE_ROLES_TO_EVENT_TYPE = [
|
||||
private const PLACE_ROLES_TO_EVENT_TYPE = [
|
||||
|
||||
// 22: Related place
|
||||
'' => 22,
|
||||
|
@ -105,4 +105,20 @@ final class MDConcPlace {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
* @param string $input Input string.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getConcordanceTarget(string $input):int {
|
||||
|
||||
if (!isset(self::PLACE_ROLES_TO_EVENT_TYPE[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown place type: " . $input);
|
||||
}
|
||||
|
||||
return self::PLACE_ROLES_TO_EVENT_TYPE[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Provides a list for finding the respective event type for a given time role.
|
||||
*/
|
||||
final class MDConcTime {
|
||||
final class MDConcTime implements MDImporterConcordanceListInterface {
|
||||
|
||||
const TIME_ROLES_TO_EVENT_TYPE = [
|
||||
private const TIME_ROLES_TO_EVENT_TYPE = [
|
||||
|
||||
# General / not yet (?) categorized
|
||||
"Laufzeit" => 24,
|
||||
|
@ -40,4 +40,20 @@ final class MDConcTime {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
* @param string $input Input string.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getConcordanceTarget(string $input):int {
|
||||
|
||||
if (!isset(self::TIME_ROLES_TO_EVENT_TYPE[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown time type: " . $input);
|
||||
}
|
||||
|
||||
return self::TIME_ROLES_TO_EVENT_TYPE[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Constains lists for resolving title type names to their internally used names.
|
||||
*/
|
||||
final class MDConcTitleTypes {
|
||||
final class MDConcTitleTypes implements MDImporterConcordanceListInterface {
|
||||
|
||||
const TITLE_TYPES = [
|
||||
private const TITLE_TYPES = [
|
||||
|
||||
// Empty
|
||||
"" => "",
|
||||
|
@ -34,4 +34,20 @@ final class MDConcTitleTypes {
|
|||
|
||||
];
|
||||
|
||||
/**
|
||||
* 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::TITLE_TYPES[$input])) {
|
||||
throw new MDImporterMissingConcordance("Unknown title type: " . $input);
|
||||
}
|
||||
|
||||
return self::TITLE_TYPES[$input];
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user