classFieldReader
final class FieldReader
Reads the value of one bold field section of a card.
Prose fields are paragraphs; list fields are bullet lists, or "None." for an empty list; labels may also be a paragraph of badge images. Link targets and label badge images are kept so that writing the card back reproduces them.
Properties§
public array<string, string> $links = []public array<string, string> $badges = []Methods§
public function read(string $name, list<Node> $nodes): mixedReads a field value.
Parameters
$name | string | The field name |
$nodes | list<Node> | The blocks of the section |
Returns
mixed The value in the shape of the YAML fieldThrows
InvalidInputException When the section is empty, has the wrong blocks or names an unknown fieldTest cases 7
FieldReaderTest::testReadReadsAListFieldcallsFieldReaderTest::testReadReadsMetadatacallsFieldReaderTest::testReadReadsNoneAsAnEmptyListcallsFieldReaderTest::testReadReadsNoneAsProseForAProseFieldcallsFieldReaderTest::testReadReadsProseFieldscallsFieldReaderTest::testReadReadsTheListOfAFieldcallsFieldReaderTest::testReadRejectsMalformedSectionscalls
Called from 1
Calls 11
- new InvalidInputException line 49
- function-call
in_arrayline 51 - method-call FieldReader::prose() line 52
- function-call
countline 54 - method-call FieldReader::evidence() line 62
- method-call FieldReader::tests() line 63
- method-call FieldReader::references() line 64
- method-call FieldReader::labels() line 65
- method-call FieldReader::design() line 66
- method-call MetadataReader::read() line 67
- new MetadataReader line 67
public function prose(list<Node> $nodes): stringReads prose paragraphs, separated by blank lines.
Parameters
$nodes | list<Node> | The blocks |
Returns
string The textThrows
InvalidInputException When a block is not a paragraph or has unsupported inline MarkdownTest cases 2
Called from 2
Calls 3
- new InvalidInputException line 86
- static-call Nodes::text() line 88
- function-call
implodeline 90
public function evidence(Node $node): list<stdClass>Reads an evidence list of bold selector fields, each followed by one block quotation.
Parameters
$node | Node | The list |
Returns
list<stdClass> The evidence entriesThrows
InvalidInputException When an entry lacks its selector or quotationTest cases 2
Called from 1
Calls 4
- static-call Nodes::items() line 105
- new InvalidInputException line 108
- static-call Nodes::pair() line 110
- method-call FieldReader::prose() line 119
public function tests(Node $node): list<stdClass>Reads a tests list of "**runner:** target" entries.
Parameters
$node | Node | The list |
Returns
list<stdClass> The test referencesThrows
InvalidInputException When an entry is not a bold runner and a targetTest cases 3
Called from 1
Calls 5
- static-call Nodes::items() line 136
- new InvalidInputException line 139
- static-call Nodes::pair() line 141
- static-call Nodes::paragraph() line 149
- function-call
property_existsline 150
public function references(Node $node): list<string>Reads a list of links to other items and remembers their targets.
Parameters
$node | Node | The list |
Returns
list<string> The linked item IDsThrows
InvalidInputException When an entry is not a single linkTest cases 2
Called from 1
Calls 4
- static-call Nodes::items() line 173
- static-call Nodes::link() line 174
- static-call Nodes::paragraph() line 174
- static-call Nodes::text() line 175
public function labels(Node $node): list<string>Reads labels from a bullet list or a paragraph of badge images.
Parameters
$node | Node | The list or paragraph |
Returns
list<string> The labelsThrows
InvalidInputException When the paragraph holds anything but badge images or no labelsTest cases 4
Called from 1
Calls 7
- function-call
array_mapline 194 - static-call Nodes::text() line 194
- static-call Nodes::paragraph() line 194
- static-call Nodes::items() line 194
- new InvalidInputException line 197
- method-call
Node::children()line 200 - function-call
trimline 201
public function design(Node $node): list<stdClass>Reads design references: links with optional text, or plain text.
Parameters
$node | Node | The list |
Returns
list<stdClass> The design referencesThrows
InvalidInputException When an entry is not a single paragraphTest cases 2
Called from 1
Calls 4
- static-call Nodes::items() line 229
- static-call Nodes::paragraph() line 230
- static-call Nodes::link() line 232
- static-call Nodes::text() line 234
Test cases 30§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 22
FieldReaderTest::testDesignReadsLinksAndTextcallsFieldReaderTest::testDesignRejectsMalformedEntriescallsFieldReaderTest::testEvidenceReadsSelectorsAndQuotationscallsFieldReaderTest::testEvidenceRejectsMalformedEntriescallsFieldReaderTest::testLabelsReadsABadgeParagraphAndRemembersTheImagescallsFieldReaderTest::testLabelsReadsABulletListcallsFieldReaderTest::testLabelsReadsBadgesOnSeveralLinescallsFieldReaderTest::testLabelsRejectsAnythingButLabelsOrBadgescallsFieldReaderTest::testProseJoinsParagraphsWithBlankLinescallsFieldReaderTest::testProseRejectsABlockThatIsNotAParagraphcallsFieldReaderTest::testReadReadsAListFieldcallsFieldReaderTest::testReadReadsMetadatacallsFieldReaderTest::testReadReadsNoneAsAnEmptyListcallsFieldReaderTest::testReadReadsNoneAsProseForAProseFieldcallsFieldReaderTest::testReadReadsProseFieldscallsFieldReaderTest::testReadReadsTheListOfAFieldcallsFieldReaderTest::testReadRejectsMalformedSectionscallsFieldReaderTest::testReferencesReadsLinkedIdsAndRemembersTheirTargetscallsFieldReaderTest::testReferencesRejectsEntriesThatAreNotASingleLinkcallsFieldReaderTest::testTestsReadsManualAndAutomaticExecutionPoliciescallsFieldReaderTest::testTestsReadsRunnersAndTargetscallsFieldReaderTest::testTestsRejectsEntriesWithoutABoldRunnercalls
Other tests reaching this symbol 8
DefinitionReaderTestcallsDocumentReaderTestcallsLoaderTestcallsCardReaderTestcallsFieldSectionsTestcallsReferenceTestcallsMarkdownDocumentTestcallsFormatterTestcalls