classCitation
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
$source | Source | The definition's source |
$file | string | The Markdown definition file |
$directory | string | The configuration directory that the source URI resolves against |
public function selector(string $url, string $quote, string|null $selector): stringDerives the evidence selector from a citation link.
Parameters
$url | string | The citation link |
$quote | string | The quoted text |
$selector | string|null | The selector written in a comment, if any |
Returns
string The selectorThrows
InvalidInputException When the link points elsewhere, disagrees with the selector or identifies no unitTest cases 2
Calls 11
- function-call
explodeline 42 - function-call
preg_matchline 44 - static-call LocalPath::normalize() line 46
- function-call
dirnameline 46 - function-call
rawurldecodeline 46 - new InvalidInputException line 48
- static-call TextFragment::isFragment() line 51
- static-call TextFragment::text() line 52
- static-call Unit::normalize() line 52
- static-call Citation::isId() line 58
- function-call
in_arrayline 63
public function validate(string $selector, string $quote): voidChecks that a Text Fragment selector identifies the complete quoted HTML unit.
Parameters
$selector | string | The selector |
$quote | string | The quoted text |
Throws
InvalidInputException When a fragment is used outside HTML or selects other textTest cases 2
Calls 4
- static-call TextFragment::isFragment() line 79
- static-call TextFragment::text() line 79
- static-call Unit::normalize() line 79
- new InvalidInputException line 80
public function url(string $selector, string $quote): stringCreates the citation link for an evidence entry.
Parameters
$selector | string | The selector |
$quote | string | The quoted text |
Returns
string The link, relative to the Markdown file for a local sourceTest cases 1
Calls 15
- function-call
explodeline 94 - function-call
preg_matchline 95 - static-call LocalPath::normalize() line 96
- function-call
dirnameline 97 - function-call
array_shiftline 99 - function-call
str_repeatline 102 - function-call
countline 102 - function-call
implodeline 102 - function-call
array_mapline 102 - function-call
rawurlencodeline 102 - static-call TextFragment::isFragment() line 104
- function-call
in_arrayline 107 - static-call Citation::isId() line 107
- function-call
substrline 108 - static-call TextFragment::create() line 110
public static function isId(string $selector): boolTells whether a selector is a single element ID.
Parameters
$selector | string | The selector |
Returns
bool True for #idTest cases 1
Called from 3
- static-call Requirements\Config\Markdown\Citation::selector() packages/requirements/src/Config/Markdown/Citation.php:58
- static-call Requirements\Config\Markdown\Citation::selector() packages/requirements/src/Config/Markdown/Citation.php:63
- static-call Requirements\Config\Markdown\Citation::url() packages/requirements/src/Config/Markdown/Citation.php:107
Calls 1
- function-call
preg_matchline 122
Private surface 3§
Implementation details, listed for orientation only.
private Source $sourceprivate string $fileprivate string $directoryTest cases 22§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
CitationTest::testIsIdTellsWhetherASelectorIsOneElementIdcallsCitationTest::testSelectorDerivesTheSelectorFromTheLinkcallsCitationTest::testSelectorRejectsCitationsThatDoNotIdentifyTheUnitcallsCitationTest::testUrlCreatesTheCitationLinkcallsCitationTest::testValidateAcceptsSelectorsThatIdentifyTheQuotecallsCitationTest::testValidateRejectsATextFragmentThatSelectsOtherTextcalls
Other tests reaching this symbol 16
DocumentReaderTestcallsCardReaderTest::testCardReadsBadgesStatementEvidenceAndFieldscallsCardReaderTest::testCardsReadsEveryCardcallsQuotationBlocksTest::testReadLeavesAParagraphWithMoreThanALinkAfterTheQuotationcallsQuotationBlocksTest::testReadReadsTheLeadingQuotationsAndTheirAttributionscallsQuotationBlocksTest::testReadRejectsAnAttributionWithAnEmptyDestinationcallsQuotationBlocksTest::testReadRejectsTwoSourceCitationscallsQuotationTest::testReadDerivesTheSelectorFromTheAttributioncallsQuotationTest::testReadDerivesTheSelectorFromTheLinkInsideTheQuotationcallsQuotationTest::testReadKeepsASelectorCommentThatTheLinkAgreesWithcallsQuotationTest::testReadReadsASelectorCommentAndTheQuotedTextcallsQuotationTest::testReadRejectsASecondSourceCitationcallsQuotationTest::testReadRejectsMalformedQuotationscallsQuotationTest::testRenderWritesTheQuotationcallsCardWriterTest::testRenderReusesTheLinksBadgesAndCitationsReadcallsMarkdownDocumentTestcalls
Relations§
Instantiated in 1
Type declarations 6
- type Requirements\Config\Markdown\CardReader packages/requirements/src/Config/Markdown/CardReader.php:26
- type Requirements\Config\Markdown\Quotation packages/requirements/src/Config/Markdown/Quotation.php:38
- type Requirements\Config\Markdown\Quotation packages/requirements/src/Config/Markdown/Quotation.php:103
- type Requirements\Config\Markdown\QuotationBlocks packages/requirements/src/Config/Markdown/QuotationBlocks.php:25
- type Requirements\Config\Markdown\Render\CardWriter packages/requirements/src/Config/Markdown/Render/CardWriter.php:39
- type Requirements\Config\MarkdownDocument packages/requirements/src/Config/MarkdownDocument.php:37