1 | <?php |
||
2 | require_once __DIR__.'/vendor/autoload.php'; |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | |||
4 | use \Dallgoot\Yaml\Yaml as Y; |
||
5 | |||
6 | /** |
||
7 | * Display some use cases for Yaml library |
||
8 | */ |
||
9 | const JSON_OPTIONS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_PARTIAL_OUTPUT_ON_ERROR; |
||
10 | |||
11 | /* USE CASE 1 |
||
12 | * load and parse if file exists |
||
13 | */ |
||
14 | ini_set("auto_detect_line_endings", 1); |
||
15 | // $yaml = Y::parseFile('./tests/cases/parsing/blockChompingWithInsideBlank.yml', null, 0); //->parse(); |
||
16 | $content = file_get_contents('./tests/cases/parsing/complex_mapping_in_item.yml');//var_dump($content); |
||
17 | $yaml = Y::parse($content, null, 2); //->parse(); |
||
18 | // $yaml = Y::parseFile('./references/Example 2.27.yml', null, 1); |
||
19 | var_dump($yaml); |
||
20 | var_dump(json_encode($yaml, JSON_OPTIONS)); |
||
21 | exit(0); |
||
22 | // USE CASE 2 |
||
23 | $a = <<<EOF |
||
24 | sequence: |
||
25 | - string_key: 1 |
||
26 | EOF; |
||
27 | $b = <<<EOF |
||
28 | #2 |
||
29 | mapping: |
||
30 | string_key: 1 |
||
31 | EOF; |
||
32 | var_dump(Y::parse($a)); |
||
33 | var_dump(Y::parse($b)); |
||
34 | |||
35 | // USE CASE 3 |
||
36 | // $yamlObjList = []; |
||
37 | // $yloader = new Loader(); |
||
38 | // foreach(['file1', 'file2', 'file3'] as $key => $fileName) |
||
39 | // { |
||
40 | // $yamlObjList[] = $yloader->load($fileName)->parse(); |
||
41 | // } |
||
42 |