sndsgd/yaml

YAML parsing enhancements for PHP

v0.0.7 2023-03-15 15:43 UTC

This package is auto-updated.

Last update: 2024-10-15 19:16:22 UTC


README

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)