Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
100
vendor/grasmash/yaml-expander/README.md
vendored
Normal file
100
vendor/grasmash/yaml-expander/README.md
vendored
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
[](https://travis-ci.org/grasmash/yaml-expander) [](https://packagist.org/packages/grasmash/yaml-expander)
|
||||
[](https://packagist.org/packages/grasmash/yaml-expander) [](https://coveralls.io/github/grasmash/yaml-expander?branch=master)
|
||||
|
||||
This tool expands property references in YAML files.
|
||||
|
||||
### Installation
|
||||
|
||||
composer require grasmash/yaml-expander
|
||||
|
||||
### Example usage:
|
||||
|
||||
Example dune.yml:
|
||||
|
||||
```yaml
|
||||
type: book
|
||||
book:
|
||||
title: Dune
|
||||
author: Frank Herbert
|
||||
copyright: ${book.author} 1965
|
||||
protaganist: ${characters.0.name}
|
||||
media:
|
||||
- hardcover
|
||||
characters:
|
||||
- name: Paul Atreides
|
||||
occupation: Kwisatz Haderach
|
||||
aliases:
|
||||
- Usul
|
||||
- Muad'Dib
|
||||
- The Preacher
|
||||
- name: Duncan Idaho
|
||||
occupation: Swordmaster
|
||||
summary: ${book.title} by ${book.author}
|
||||
product-name: ${${type}.title}
|
||||
```
|
||||
|
||||
Property references use dot notation to indicate array keys, and must be wrapped in `${}`.
|
||||
|
||||
Expansion logic:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Parse a yaml string directly, expanding internal property references.
|
||||
$yaml_string = file_get_contents("dune.yml");
|
||||
$expanded = \Grasmash\YamlExpander\Expander::parse($yaml_string);
|
||||
print_r($expanded);
|
||||
|
||||
// Parse an array, expanding internal property references.
|
||||
$array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
|
||||
$expanded = \Grasmash\YamlExpander\Expander::expandArrayProperties($array);
|
||||
print_r($expanded);
|
||||
|
||||
// Parse an array, expanding references using both internal and supplementary values.
|
||||
$array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
|
||||
$reference_properties = ['book' => ['publication-year' => 1965]];
|
||||
$expanded = \Grasmash\YamlExpander\Expander::expandArrayProperties($array, $reference_properties);
|
||||
print_r($expanded);
|
||||
````
|
||||
|
||||
Resultant array:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
array (
|
||||
'type' => 'book',
|
||||
'book' =>
|
||||
array (
|
||||
'title' => 'Dune',
|
||||
'author' => 'Frank Herbert',
|
||||
'copyright' => 'Frank Herbert 1965',
|
||||
'protaganist' => 'Paul Atreides',
|
||||
'media' =>
|
||||
array (
|
||||
0 => 'hardcover',
|
||||
),
|
||||
),
|
||||
'characters' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'name' => 'Paul Atreides',
|
||||
'occupation' => 'Kwisatz Haderach',
|
||||
'aliases' =>
|
||||
array (
|
||||
0 => 'Usul',
|
||||
1 => 'Muad\'Dib',
|
||||
2 => 'The Preacher',
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'name' => 'Duncan Idaho',
|
||||
'occupation' => 'Swordmaster',
|
||||
),
|
||||
),
|
||||
'summary' => 'Dune by Frank Herbert',
|
||||
'product-name' => 'Dune',
|
||||
);
|
||||
```
|
||||
Reference in a new issue