@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Config Trait |
|
4 | - * |
|
5 | - * @package BrightNucleus\Config |
|
6 | - * @author Alain Schlesser <[email protected]> |
|
7 | - * @license GPL-2.0+ |
|
8 | - * @link http://www.brightnucleus.com/ |
|
9 | - * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
10 | - */ |
|
3 | + * Config Trait |
|
4 | + * |
|
5 | + * @package BrightNucleus\Config |
|
6 | + * @author Alain Schlesser <[email protected]> |
|
7 | + * @license GPL-2.0+ |
|
8 | + * @link http://www.brightnucleus.com/ |
|
9 | + * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | namespace BrightNucleus\Config; |
13 | 13 | |
@@ -18,98 +18,98 @@ discard block |
||
18 | 18 | trait ConfigTrait |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Reference to the Config object. |
|
23 | - * |
|
24 | - * @since 0.1.2 |
|
25 | - * |
|
26 | - * @var ConfigInterface |
|
27 | - */ |
|
28 | - protected $config; |
|
21 | + /** |
|
22 | + * Reference to the Config object. |
|
23 | + * |
|
24 | + * @since 0.1.2 |
|
25 | + * |
|
26 | + * @var ConfigInterface |
|
27 | + */ |
|
28 | + protected $config; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Process the passed-in configuration file. |
|
32 | - * |
|
33 | - * @since 0.1.2 |
|
34 | - * |
|
35 | - * @param ConfigInterface $config The Config to process. |
|
36 | - * @param string ... List of keys. |
|
37 | - * @throws RuntimeException If the arguments could not be parsed into a Config. |
|
38 | - */ |
|
39 | - protected function processConfig(ConfigInterface $config) |
|
40 | - { |
|
41 | - if (func_num_args() > 1) { |
|
42 | - try { |
|
43 | - $keys = func_get_args(); |
|
44 | - array_shift($keys); |
|
45 | - $config = new Config($config->getKey($keys)); |
|
46 | - } catch (Exception $exception) { |
|
47 | - throw new RuntimeException(sprintf( |
|
48 | - _('Could not process the config with the arguments "%1$s".'), |
|
49 | - print_r(func_get_args(), true) |
|
50 | - )); |
|
51 | - } |
|
52 | - } |
|
53 | - $this->config = $config; |
|
54 | - } |
|
30 | + /** |
|
31 | + * Process the passed-in configuration file. |
|
32 | + * |
|
33 | + * @since 0.1.2 |
|
34 | + * |
|
35 | + * @param ConfigInterface $config The Config to process. |
|
36 | + * @param string ... List of keys. |
|
37 | + * @throws RuntimeException If the arguments could not be parsed into a Config. |
|
38 | + */ |
|
39 | + protected function processConfig(ConfigInterface $config) |
|
40 | + { |
|
41 | + if (func_num_args() > 1) { |
|
42 | + try { |
|
43 | + $keys = func_get_args(); |
|
44 | + array_shift($keys); |
|
45 | + $config = new Config($config->getKey($keys)); |
|
46 | + } catch (Exception $exception) { |
|
47 | + throw new RuntimeException(sprintf( |
|
48 | + _('Could not process the config with the arguments "%1$s".'), |
|
49 | + print_r(func_get_args(), true) |
|
50 | + )); |
|
51 | + } |
|
52 | + } |
|
53 | + $this->config = $config; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Check whether the Config has a specific key. |
|
58 | - * |
|
59 | - * To get a value several levels deep, add the keys for each level as a comma-separated list. |
|
60 | - * |
|
61 | - * @since 0.1.2 |
|
62 | - * @since 0.1.5 Accepts list of keys. |
|
63 | - * |
|
64 | - * @param string ... List of keys. |
|
65 | - * @return bool Whether the key is known. |
|
66 | - */ |
|
67 | - protected function hasConfigKey() |
|
68 | - { |
|
69 | - $keys = func_get_args(); |
|
56 | + /** |
|
57 | + * Check whether the Config has a specific key. |
|
58 | + * |
|
59 | + * To get a value several levels deep, add the keys for each level as a comma-separated list. |
|
60 | + * |
|
61 | + * @since 0.1.2 |
|
62 | + * @since 0.1.5 Accepts list of keys. |
|
63 | + * |
|
64 | + * @param string ... List of keys. |
|
65 | + * @return bool Whether the key is known. |
|
66 | + */ |
|
67 | + protected function hasConfigKey() |
|
68 | + { |
|
69 | + $keys = func_get_args(); |
|
70 | 70 | |
71 | - return $this->config->hasKey($keys); |
|
72 | - } |
|
71 | + return $this->config->hasKey($keys); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Get the Config value for a specific key. |
|
76 | - * |
|
77 | - * To get a value several levels deep, add the keys for each level as a comma-separated list. |
|
78 | - * |
|
79 | - * @since 0.1.2 |
|
80 | - * @since 0.1.5 Accepts list of keys. |
|
81 | - * |
|
82 | - * @param string ... List of keys. |
|
83 | - * @return mixed Value of the key. |
|
84 | - */ |
|
85 | - protected function getConfigKey() |
|
86 | - { |
|
87 | - $keys = func_get_args(); |
|
74 | + /** |
|
75 | + * Get the Config value for a specific key. |
|
76 | + * |
|
77 | + * To get a value several levels deep, add the keys for each level as a comma-separated list. |
|
78 | + * |
|
79 | + * @since 0.1.2 |
|
80 | + * @since 0.1.5 Accepts list of keys. |
|
81 | + * |
|
82 | + * @param string ... List of keys. |
|
83 | + * @return mixed Value of the key. |
|
84 | + */ |
|
85 | + protected function getConfigKey() |
|
86 | + { |
|
87 | + $keys = func_get_args(); |
|
88 | 88 | |
89 | - return $this->config->getKey($keys); |
|
90 | - } |
|
89 | + return $this->config->getKey($keys); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Get a (multi-dimensional) array of all the configuration settings. |
|
94 | - * |
|
95 | - * @since 0.1.4 |
|
96 | - * |
|
97 | - * @return array All the configuration settings. |
|
98 | - */ |
|
99 | - protected function getConfigArray() |
|
100 | - { |
|
101 | - return $this->config->getAll(); |
|
102 | - } |
|
92 | + /** |
|
93 | + * Get a (multi-dimensional) array of all the configuration settings. |
|
94 | + * |
|
95 | + * @since 0.1.4 |
|
96 | + * |
|
97 | + * @return array All the configuration settings. |
|
98 | + */ |
|
99 | + protected function getConfigArray() |
|
100 | + { |
|
101 | + return $this->config->getAll(); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Get an array of all the keys that are known by the Config. |
|
106 | - * |
|
107 | - * @since 0.1.2 |
|
108 | - * |
|
109 | - * @return array Array of strings containing all the keys. |
|
110 | - */ |
|
111 | - protected function getConfigKeys() |
|
112 | - { |
|
113 | - return $this->config->getKeys(); |
|
114 | - } |
|
104 | + /** |
|
105 | + * Get an array of all the keys that are known by the Config. |
|
106 | + * |
|
107 | + * @since 0.1.2 |
|
108 | + * |
|
109 | + * @return array Array of strings containing all the keys. |
|
110 | + */ |
|
111 | + protected function getConfigKeys() |
|
112 | + { |
|
113 | + return $this->config->getKeys(); |
|
114 | + } |
|
115 | 115 | } |