Add enum MDNodaRepository and class MDNodaLink for the overarching data
structure
This commit is contained in:
34
src/classes/MDNodaLink.php
Normal file
34
src/classes/MDNodaLink.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Describes a reference to an external norm data repository.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Describes a reference to an external norm data repository.
|
||||
*/
|
||||
final class MDNodaLink {
|
||||
|
||||
public readonly MDNodaRepository $source;
|
||||
public readonly string $id;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param MDNodaRepository $source Source repository.
|
||||
* @param string $id ID.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MDNodaRepository $source, string $id) {
|
||||
|
||||
$this->source = $source;
|
||||
if (($validatedId = $this->source->validateId(trim($id))) === false) {
|
||||
throw new MDInvalidNodaLink("Invalid noda ID / link: " . $id . " [Repository: " . $this->source->toDbName() . "]");
|
||||
}
|
||||
$this->id = $validatedId;
|
||||
|
||||
}
|
||||
}
|
1
src/classes/README.md
Normal file
1
src/classes/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Full-scale data types that provide further functionality but end up representing base data types
|
Reference in New Issue
Block a user