YamlParser
extends Parser
in package
Class YamlParser.
Table of Contents
- parse() : array<string|int, mixed>
- Parses an YAML file.
- addChild() : void
- Recursively adds childs to an array tree.
- checkConfig() : void
- Check for config issues.
- getValue() : array<int|string, mixed>|bool|float|int|string|null
- Interprets a string value and returns it with a PHP type.
- ksortRecursive() : mixed
- Sort arrays by keys recursively.
- parseOrThrow() : array<int|string, mixed>
Methods
parse()
Parses an YAML file.
public
static parse(mixed $config) : array<string|int, mixed>
Parameters
- $config : mixed
-
path to the YAML file
Tags
Return values
array<string|int, mixed> —The YAML parsed data
addChild()
Recursively adds childs to an array tree.
protected
static addChild(array<int|string, mixed> &$parent, array<int|string, mixed> $childs, mixed $value) : void
Parameters
- $parent : array<int|string, mixed>
-
The main array, where the childs will be added
- $childs : array<int|string, mixed>
-
Childs to add
- $value : mixed
-
The last child value
Return values
void —checkConfig()
Check for config issues.
protected
static checkConfig(mixed $config) : void
Parameters
- $config : mixed
-
The parser configuration
Tags
Return values
void —getValue()
Interprets a string value and returns it with a PHP type.
protected
static getValue(string $value) : array<int|string, mixed>|bool|float|int|string|null
Parameters
- $value : string
-
The input value
Return values
array<int|string, mixed>|bool|float|int|string|null —The output value
ksortRecursive()
Sort arrays by keys recursively.
protected
static ksortRecursive(mixed $value) : mixed
Parameters
- $value : mixed
-
The input value
Return values
mixed —The output value (sorted by keys if the $value is an array)
parseOrThrow()
protected
static parseOrThrow(Closure $function) : array<int|string, mixed>
Parameters
- $function : Closure