Skip to content

sndsgd/yaml

Repository files navigation

sndsgd/yaml

Latest Version Software License Build Status

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

  1. 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,
    );
  2. Parse strings with ->parse(string $yaml, int $maxDocuments)

  3. Parse files with ->parseFile(string $path, int $maxDocuments)