classFrontmatter
final class Frontmatter
Splits a Markdown definition into its YAML frontmatter and its card body.
The frontmatter is delimited by --- lines and may hold only $schema, version and source.
Methods§
public function read(string $file): array{stdClass, string}Reads a Markdown definition file.
Parameters
$file | string | The definition file |
Returns
array{stdClass, string} The frontmatter and the body after itThrows
InvalidInputException When the file has no frontmatter, it is not a mapping or has unknown keysParseException When the frontmatter is malformed YAMLTest cases 7
FrontmatterTest::testReadAcceptsCarriageReturnLineFeedscallsFrontmatterTest::testReadReadsTheSourceAsAMappingcallsFrontmatterTest::testReadRejectsAFileWithoutFrontmattercallsFrontmatterTest::testReadRejectsFrontmatterThatIsNotAMappingcallsFrontmatterTest::testReadRejectsMalformedYamlcallsFrontmatterTest::testReadRejectsUnknownFrontmatterKeyscallsFrontmatterTest::testReadSplitsTheFrontmatterFromTheBodycalls
Called from 1
Calls 9
- function-call
file_get_contentsline 32 - function-call
preg_matchline 33 - new InvalidInputException line 34
- static-call
Yaml::parse()line 36 - class-const
Yaml::PARSE_OBJECT_FOR_MAP()line 36 - class-const
Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE()line 36 - static-call Fields::keys() line 40
- static-call Fields::mapping() line 40
- function-call
get_object_varsline 40
Test cases 13§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
FrontmatterTest::testReadAcceptsCarriageReturnLineFeedscallsFrontmatterTest::testReadReadsTheSourceAsAMappingcallsFrontmatterTest::testReadRejectsAFileWithoutFrontmattercallsFrontmatterTest::testReadRejectsFrontmatterThatIsNotAMappingcallsFrontmatterTest::testReadRejectsMalformedYamlcallsFrontmatterTest::testReadRejectsUnknownFrontmatterKeyscallsFrontmatterTest::testReadSplitsTheFrontmatterFromTheBodycalls
Other tests reaching this symbol 6
DefinitionReaderTestcallsDocumentReaderTestcallsLoaderTestcallsReferenceTestcallsMarkdownDocumentTestcallsFormatterTestcalls