sndsgd / yaml
YAML parsing enhancements for PHP
Installs: 1 124
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- ext-yaml: *
- sndsgd/util: >=2.1.0
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan: 1.4.6
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: 9.5.13
- slevomat/coding-standard: ~8
- squizlabs/php_codesniffer: 3.*
README
YAML parsing enhancements for PHP.
Context
The sndsgd\yaml\ParserContext
object is a data bag you can jam things into for use in callbacks.
Callbacks
You can define your own callbacks by implementing sndsgd\yaml\Callback
. This repository contains an example: sndsgd\yaml\callbacks\SecondsCallback
.
Parsing
-
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)