classCardWriter
final class CardWriter
Writes a definition as Markdown cards in the canonical layout.
Each card has its badges, statement, evidence quotations and then its fields in a fixed order; badge images, link targets and citations read from the original are reused.
Methods§
public function render(
stdClass $data,
array<string, array<string, array<string, string>>> $links,
array<string, array<string, array<string, array{url: string, title: ?string}>>> $badges,
array<string, list<array{url: string, label: string}|null>> $citations = [],
Citation|null $source = null,
): stringWrites a definition.
Parameters
$data | stdClass | The definition |
$links | array<string, array<string, array<string, string>>> | Link targets by item ID, field and linked ID |
$badges | array<string, array<string, array<string, array{url: string, title: ?string}>>> | Badge images by item ID, field and value |
$citations | array<string, list<array{url: string, label: string}|null>> | Citation links by item ID |
$source | Citation|null | Creates citation links for the definition's source |
Returns
string The Markdown textThrows
InvalidInputException When a record cannot be written as a cardJsonException When a metadata value cannot be encodedTest cases 5
CardWriterTest::testRenderEscapesTheStatementcallsCardWriterTest::testRenderRejectsRecordsThatCannotBeCardscallsCardWriterTest::testRenderReusesTheLinksBadgesAndCitationsReadcallsCardWriterTest::testRenderWritesADefinitionWithoutItemscallsCardWriterTest::testRenderWritesEveryFieldInTheCanonicalOrdercalls
Called from 1
Calls 13
- static-call DocumentReader::yaml() line 43
- new FieldWriter line 44
- static-call Fields::sequence() line 45
- static-call Record::fields() line 46
- static-call Fields::text() line 47
- static-call Badges::render() line 53
- static-call Fields::strings() line 56
- function-call
implodeline 60 - static-call Nodes::escape() line 62
- static-call Quotation::render() line 65
- function-call
array_key_existsline 68 - function-call
in_arrayline 68 - method-call FieldWriter::write() line 72
Test cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
CardWriterTest::testRenderEscapesTheStatementcallsCardWriterTest::testRenderRejectsRecordsThatCannotBeCardscallsCardWriterTest::testRenderReusesTheLinksBadgesAndCitationsReadcallsCardWriterTest::testRenderWritesADefinitionWithoutItemscallsCardWriterTest::testRenderWritesEveryFieldInTheCanonicalOrdercalls
Other tests reaching this symbol 2
MarkdownDocumentTestcallsFormatterTestcalls