1 | <?php |
||
12 | class ComposerExtra |
||
13 | { |
||
14 | use PresetsAwareTrait; |
||
15 | use ComposerJsonAwareTrait; |
||
16 | |||
17 | protected $config; |
||
18 | protected $namespace; |
||
19 | protected $defaultConfig; |
||
20 | protected $presetsPath; |
||
21 | |||
22 | /** |
||
23 | * Merge configurations. |
||
24 | * |
||
25 | * @var callable |
||
26 | */ |
||
27 | public $merge = '\Schnittstabil\ConfigMerge\config_merge'; |
||
28 | |||
29 | /** |
||
30 | * Create a new ComposerExtra. |
||
31 | * |
||
32 | * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValue` |
||
33 | * |
||
34 | * @param string|int|mixed[] $namespace a `Schnittstabil\Get\getValue` path |
||
35 | * @param mixed $defaultConfig default configuration |
||
36 | * @param string $presetsPath presets path (w/o namespace) |
||
37 | * |
||
38 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
39 | */ |
||
40 | public function __construct($namespace = array(), $defaultConfig = null, $presetsPath = null) |
||
47 | |||
48 | /** |
||
49 | * Merge two configs. |
||
50 | * |
||
51 | * @param mixed $target Target config |
||
52 | * @param mixed $source Source config |
||
53 | * |
||
54 | * @return mixed The merged config |
||
55 | */ |
||
56 | protected function merge($target, $source) |
||
64 | |||
65 | /** |
||
66 | * Get the configuration. |
||
67 | * |
||
68 | * @return mixed the configuration |
||
69 | */ |
||
70 | protected function getConfig() |
||
90 | |||
91 | /** |
||
92 | * Get configuration value. |
||
93 | * |
||
94 | * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValue` |
||
95 | * |
||
96 | * @param string|int|mixed[] $path a `Schnittstabil\Get\getValue` path |
||
97 | * @param mixed $default default value if $path is not valid |
||
98 | * |
||
99 | * @return mixed the value determined by `$path` or otherwise `$default` |
||
100 | */ |
||
101 | public function get($path = array(), $default = null) |
||
105 | |||
106 | /** |
||
107 | * Get configuration value. |
||
108 | * |
||
109 | * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValueOrFail` |
||
110 | * |
||
111 | * @param string|int|mixed[] $path a `Schnittstabil\Get\getValueOrFail` path |
||
112 | * @param mixed $message exception message |
||
113 | * |
||
114 | * @throws \OutOfBoundsException if `$path` is not valid |
||
115 | * |
||
116 | * @return mixed the value determined by `$path` |
||
117 | */ |
||
118 | public function getOrFail($path = array(), $message = null) |
||
122 | } |
||
123 |