1 | <?php |
||
13 | class ComposerExtra |
||
14 | { |
||
15 | use PresetsAwareTrait; |
||
16 | |||
17 | protected $config; |
||
18 | protected $namespace; |
||
19 | protected $defaultConfig; |
||
20 | protected $presetsPath; |
||
21 | protected $composerJson; |
||
22 | |||
23 | /** |
||
24 | * Merge configurations. |
||
25 | * |
||
26 | * @var callable |
||
27 | */ |
||
28 | public $merge = '\Schnittstabil\ConfigMerge\config_merge'; |
||
29 | |||
30 | /** |
||
31 | * Create a new ComposerExtra. |
||
32 | * |
||
33 | * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValue` |
||
34 | * |
||
35 | * @param string|int|mixed[] $namespace a `Schnittstabil\Get\getValue` path |
||
36 | * @param mixed $defaultConfig default configuration |
||
37 | * @param string $presetsPath presets path (w/o namespace) |
||
38 | * |
||
39 | * @throws \KHerGe\File\Exception\FileException |
||
40 | * @throws \Seld\JsonLint\ParsingException |
||
41 | * |
||
42 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
43 | */ |
||
44 | public function __construct($namespace = array(), $defaultConfig = null, $presetsPath = null) |
||
52 | |||
53 | /** |
||
54 | * Merge two configs. |
||
55 | * |
||
56 | * @param mixed $target Target config |
||
57 | * @param mixed $source Source config |
||
58 | * |
||
59 | * @return mixed The merged config |
||
60 | */ |
||
61 | protected function merge($target, $source) |
||
69 | |||
70 | /** |
||
71 | * Get the configuration. |
||
72 | * |
||
73 | * @return mixed the configuration |
||
74 | */ |
||
75 | protected function getConfig() |
||
95 | |||
96 | /** |
||
97 | * Get configuration value. |
||
98 | * |
||
99 | * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValue` |
||
100 | * |
||
101 | * @param string|int|mixed[] $path a `Schnittstabil\Get\getValue` path |
||
102 | * @param mixed $default default value if $path is not valid |
||
103 | * |
||
104 | * @return mixed the value determined by `$path` or otherwise `$default` |
||
105 | */ |
||
106 | public function get($path = array(), $default = null) |
||
110 | |||
111 | /** |
||
112 | * Get configuration value. |
||
113 | * |
||
114 | * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValueOrFail` |
||
115 | * |
||
116 | * @param string|int|mixed[] $path a `Schnittstabil\Get\getValueOrFail` path |
||
117 | * @param mixed $message exception message |
||
118 | * |
||
119 | * @throws \OutOfBoundsException if `$path` is not valid |
||
120 | * |
||
121 | * @return mixed the value determined by `$path` |
||
122 | */ |
||
123 | public function getOrFail($path = array(), $message = null) |
||
127 | } |
||
128 |