final class Citation

Links quoted evidence to the unit of the definition's source it quotes.

A citation links to the source resource, relative to the Markdown file for a local source, with an element-ID anchor or an exact Text Fragment that identifies the quoted unit.

Methods§

public function __construct(
    private Source $source,
    private string $file,
    private string $directory,
)

Parameters

$sourceSourceThe definition's source
$filestringThe Markdown definition file
$directorystringThe configuration directory that the source URI resolves against
public function selector(string $url, string $quote, string|null $selector): string

Derives the evidence selector from a citation link.

Parameters

$urlstringThe citation link
$quotestringThe quoted text
$selectorstring|nullThe selector written in a comment, if any

Returns

string The selector

Throws

InvalidInputException When the link points elsewhere, disagrees with the selector or identifies no unit
Test cases 2
Calls 11
public function validate(string $selector, string $quote): void

Checks that a Text Fragment selector identifies the complete quoted HTML unit.

Parameters

$selectorstringThe selector
$quotestringThe quoted text

Throws

InvalidInputException When a fragment is used outside HTML or selects other text
Test cases 2
Calls 4
public function url(string $selector, string $quote): string

Creates the citation link for an evidence entry.

Parameters

$selectorstringThe selector
$quotestringThe quoted text

Returns

string The link, relative to the Markdown file for a local source
Test cases 1
Calls 15
public static function isId(string $selector): bool

Private surface 3§

Implementation details, listed for orientation only.

private Source $source
private string $file
private string $directory

Test cases 22§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 6
Other tests reaching this symbol 16

Relations§

Instantiated in 1
Type declarations 6