Yaml

Yaml helper class

 class Winter\Storm\Parse\Yaml

Properties

protected $processor : YamlProcessor | null

active YAML processor instance

Methods

public parse (string $contents) : mixed

Parses supplied YAML contents in to a PHP array.

Parameters
Property Description
$contents
string

YAML contents to parse.

Returns
mixed

The YAML contents.

public parseFile (string $fileName) : mixed

Parses YAML file contents in to a PHP array.

Parameters
Property Description
$fileName
string

File to read contents and parse.

Returns
mixed

The YAML contents.

public removeProcessor () : static

Removes the current processor.

Returns
static

public render (array $vars = [], array $options = []) : string

Renders a PHP array to YAML format.

Supported options:

  • inline: The level where you switch to inline YAML.
  • exceptionOnInvalidType: if an exception must be thrown on invalid types.
  • objectSupport: if object support is enabled.
Parameters
Property Description
$vars
array
$options
array
Returns
string

public setProcessor (Winter\Storm\Parse\Processor\Contracts\YamlProcessor $processor) : static

Sets a processor.

Parameters
Property Description
$processor
Winter\Storm\Parse\Processor\Contracts\YamlProcessor
Returns
static

public withProcessor (Winter\Storm\Parse\Processor\Contracts\YamlProcessor $processor, callable $callback) : mixed

Temporarily uses a processor for the YAML parser within a callback.

Once the callback is fired, any previous active processor will be restored.

Parameters
Property Description
$processor
Winter\Storm\Parse\Processor\Contracts\YamlProcessor
$callback
callable
Returns
mixed
Copyright © 2024 Winter CMS