Files
MDAllowedValueSets/src/classes/MDNodaLink.php

46 lines
1.1 KiB
PHP

<?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;
/**
* Returns the link to the current entity.
*
* @return string
*/
public function getEntityLink():string {
return $this->source->getEntityLink($this->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(strtr(trim($id), [" " => "", "\t" => "", "\n" => ""]))) === false) {
throw new MDInvalidNodaLink("Invalid norm data ID / link: \"" . $id . "\" [Repository: " . $this->source->toDbName() . "]");
}
$this->id = $validatedId;
}
}