YAML parsing enhancements for PHP.
The sndsgd\yaml\ParserContext
object is a data bag you can jam things into for use in callbacks.
You can define your own callbacks by implementing sndsgd\yaml\Callback
. This repository contains an example: sndsgd\yaml\callbacks\SecondsCallback
.
-
Create a parser instance with all your callbacks
$parser = new sndsgd\yaml\Parser( new sndsgd\yaml\ParserContext(), sndsgd\yaml\callbacks\SecondsCallback::class, your\fun\CoolCallback::class, );
-
Parse strings with
->parse(string $yaml, int $maxDocuments)
-
Parse files with
->parseFile(string $path, int $maxDocuments)