classQuotation
final class Quotation
Reads and writes one evidence quotation of a card.
A quotation may start with a selector comment and end with a paragraph holding its source link; its other paragraphs are the quoted text.
Properties§
public array{url: string, label: string}|null $link = nullMethods§
public function read(
BlockQuote $node,
Citation|null $citation,
Link|null $attribution = null,
): stdClassReads a quotation.
Parameters
$node | BlockQuote | The block quotation |
$citation | Citation|null | Resolves the citation against the definition's source |
$attribution | Link|null | The source link written after the quotation, if any |
Returns
stdClass The evidence entry with its selector and quoteThrows
InvalidInputException When the definition has no source, the quotation is malformed or no selector is givenTest cases 7
QuotationTest::testReadDerivesTheSelectorFromTheAttributioncallsQuotationTest::testReadDerivesTheSelectorFromTheLinkInsideTheQuotationcallsQuotationTest::testReadKeepsASelectorCommentThatTheLinkAgreesWithcallsQuotationTest::testReadReadsASelectorCommentAndTheQuotedTextcallsQuotationTest::testReadRejectsAQuotationWithoutADeclaredSourcecallsQuotationTest::testReadRejectsASecondSourceCitationcallsQuotationTest::testReadRejectsMalformedQuotationscalls
Called from 1
Calls 8
- new InvalidInputException line 41
- static-call Nodes::text() line 43
- method-call
BlockQuote::children()line 46 - method-call
BlockQuote::firstChild()line 47 - static-call Quotation::annotation() line 48
- static-call Nodes::link() line 53
- function-call
implodeline 61 - function-call
trimline 62
public static function annotation(HtmlBlock $node): stringReads the selector comment that may start a quotation.
Parameters
$node | HtmlBlock | The HTML block |
Returns
string The selectorThrows
InvalidInputException When the block is anything but a single selector commentTest cases 2
Called from 2
Calls 9
- method-call
HtmlBlock::getType()line 86 - class-const
HtmlBlock::TYPE_2_COMMENT()line 86 - function-call
preg_matchline 86 - method-call
HtmlBlock::getLiteral()line 86 - function-call
str_containsline 86 - new InvalidInputException line 87
- function-call
html_entity_decodeline 89 - function-call
str_starts_withline 90 - function-call
substrline 90
public static function render(
string $selector,
string $quote,
Citation|null $citation,
array{url: string, label: string}|null $link,
): stringWrites a quotation, with a selector comment unless the citation link identifies the unit.
Parameters
$selector | string | The selector |
$quote | string | The quoted text |
$citation | Citation|null | Creates the citation link |
$link | array{url: string, label: string}|null | The citation link read with the quotation |
Returns
string The Markdown quotationTest cases 4
Called from 1
Calls 4
- function-call
htmlspecialcharsline 114 - function-call
str_replaceline 115 - static-call Nodes::escape() line 115
- static-call Nodes::destination() line 117
Test cases 19§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 13
QuotationTest::testAnnotationReadsTheSelectorCommentcallsQuotationTest::testAnnotationRejectsAnythingButASelectorCommentcallsQuotationTest::testReadDerivesTheSelectorFromTheAttributioncallsQuotationTest::testReadDerivesTheSelectorFromTheLinkInsideTheQuotationcallsQuotationTest::testReadKeepsASelectorCommentThatTheLinkAgreesWithcallsQuotationTest::testReadReadsASelectorCommentAndTheQuotedTextcallsQuotationTest::testReadRejectsAQuotationWithoutADeclaredSourcecallsQuotationTest::testReadRejectsASecondSourceCitationcallsQuotationTest::testReadRejectsMalformedQuotationscallsQuotationTest::testRenderEscapesTheSelectorCommentcallsQuotationTest::testRenderKeepsTheReadLinkWithoutACitationcallsQuotationTest::testRenderWritesASelectorCommentWithoutACitationcallsQuotationTest::testRenderWritesTheQuotationcalls
Other tests reaching this symbol 6
CardReaderTestcallsAllowedBlocksTestcallsDocumentSchemaTestcallsQuotationBlocksTestcallsCardWriterTestcallsMarkdownDocumentTestcalls