final class MetadataReader

Reads the metadata field: nested lists of "**key:** value" entries or plain values.

A value is decoded as JSON when it is valid JSON and kept as text otherwise; a parent entry with an empty value (or [] in a sequence) holds one nested list.

Methods§

public function read(Node $node): stdClass

Reads the metadata mapping.

Parameters

$nodeNodeA paragraph holding a JSON object, or a bullet list of keys

Returns

stdClass The metadata

Throws

InvalidInputException When the value is not a mapping or the lists are malformed
Test cases 4
Called from 1
Calls 4
public function nested(Node $node): stdClass|list<mixed>
public function scalar(string $text): mixed

Reads a scalar value.

Parameters

$textstringThe written value

Returns

mixed The decoded JSON value, or the text when it is not JSON

Throws

InvalidInputException When the value is empty
Test cases 2
Called from 2
Calls 3

Test cases 14§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 11
Other tests reaching this symbol 3

Relations§

Instantiated in 1
Method calls 1