-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
64 lines (50 loc) · 1.52 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
require( __DIR__ . '/vendor/autoload.php' );
use ItalyStrap\Config\ConfigFactory;
$config = ConfigFactory::make([ 'test' => 'value', 'test2' => 'value2' ], [ 'test' => null ]);
\print_r($config);
\print_r($config->get( 'key-does-not-exists' ));
\print_r($config->get( 'test' ));
\print_r($config->has( 'key-does-not-exists' ));
\print_r($config->has( 'test' ));
$default = [
'key' => 'value',
'key1' => [
'subKey' => 'someValue',
],
];
$config->merge( $default )->merge(
[
'key1' => [
'subKey' => 'someValuedfgasedga',
'nested' => [
'subSubKey' => 'nestedValue'
]
]
]
);
\print_r($config->get('key1.subKey'));
\print_r($config->get(['key1', 'subKey']));
\print_r($config->get('key1'));
\print_r($config->get('key2'));
\print_r($config->get('key1.subKey'));
\print_r($config->get('key1.nested.subSubKey'));
\print_r($config->get(['key1', 'nested', 'subSubKey']));
\print_r($config->get('key1.nested.subSubKeyfdgd'));
\print_r($config->merge(['key1' => [1]]));
\print_r($config['key1']['subKe'] ?? '');
\print_r($config->key1['subKey'] ?? '');
\print_r($config->key1->subKey ?? '');
\print_r($config->getArrayCopy());
\print_r($config->get('test_null'));
\print_r($config->get('test'));
\print_r($config->get('undefined'));
\print_r( PHP_EOL );
\print_r( PHP_EOL );
$config = ConfigFactory::make();
$generator = function (): \Traversable {
yield 'key' => 'val';
};
$config->merge($generator());
\print_r($config->get('key'));