classCardReader
final class CardReader
Reads the item cards of a Markdown definition body.
A card is an ATX "# ID" heading followed by badge rows, one statement paragraph, evidence quotations and bold field sections, in that order.
Methods§
public function __construct(private Presentation $presentation, private Citation|null $source)Parameters
$presentation | Presentation | Receives the badges, citations and links of each card |
$source | Citation|null | Resolves citations against the definition's source |
public function cards(Document $document, string $body, string $file): list<stdClass>Reads every card of a document.
Parameters
$document | Document | The parsed body |
$body | string | The body text, used to check the heading syntax |
$file | string | The definition file |
Returns
list<stdClass> The itemsThrows
InvalidInputException When a heading is not written as "# ID" or a card is malformedTest cases 5
Called from 1
Calls 5
- function-call
explodeline 43 - method-call
Document::children()line 47 - function-call
preg_matchline 49 - new InvalidInputException line 50
- method-call CardReader::card() line 53
public function card(Heading $heading, list<Node> $blocks, string $file): stdClassReads one card.
Parameters
$heading | Heading | The heading holding the item ID |
$blocks | list<Node> | The blocks up to the next heading |
$file | string | The definition file |
Returns
stdClass The itemThrows
InvalidInputException When the card lacks a statement or a badge, quotation or field is malformedTest cases 4
Called from 2
Calls 13
- static-call Nodes::text() line 80
- new
stdClassline 81 - new Badges line 83
- static-call Badges::isParagraph() line 84
- method-call Badges::read() line 85
- function-call
array_shiftline 86 - static-call Nodes::field() line 90
- new InvalidInputException line 91
- function-call
preg_replaceline 93 - method-call QuotationBlocks::read() line 94
- new QuotationBlocks line 94
- method-call FieldSections::read() line 98
- new FieldSections line 98
Private surface 2§
Implementation details, listed for orientation only.
private Presentation $presentationprivate Citation|null $sourceTest cases 15§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
CardReaderTest::testCardLeavesOutEvidenceWhenThereIsNoQuotationcallsCardReaderTest::testCardReadsBadgesStatementEvidenceAndFieldscallsCardReaderTest::testCardRejectsACardWithoutAStatementcallsCardReaderTest::testCardRejectsInlineMarkdownInTheStatementcallsCardReaderTest::testCardsAcceptsATabAfterTheHashcallsCardReaderTest::testCardsIgnoresBlocksBeforeTheFirstHeadingcallsCardReaderTest::testCardsReadsEveryCardcallsCardReaderTest::testCardsReadsNothingFromABodyWithoutHeadingscallsCardReaderTest::testCardsRejectsHeadingsNotWrittenAsAtxcalls
Other tests reaching this symbol 6
DefinitionReaderTestcallsDocumentReaderTestcallsLoaderTestcallsReferenceTestcallsMarkdownDocumentTestcallsFormatterTestcalls