1 | <?php |
||
12 | class Config implements ArrayAccess, ConfigInterface |
||
13 | { |
||
14 | /** the config key for the list of handlers */ |
||
15 | const KEY_HANDLERS = 'handlers'; |
||
16 | /** the config key for the DI provider */ |
||
17 | const KEY_DI = 'di'; |
||
18 | /** the config key for the list of handler options */ |
||
19 | const KEY_OPTIONS = 'options'; |
||
20 | /** the config key for a class */ |
||
21 | const KEY_CLASS = 'class'; |
||
22 | /** the config key for a file */ |
||
23 | const KEY_FILE = 'file'; |
||
24 | /** the config key for the list of services (deprecated) */ |
||
25 | const KEY_SERVICES = 'services'; |
||
26 | /** the config key for the list of controllers */ |
||
27 | const KEY_CONTROLLERS = 'services'; |
||
28 | /** the config key for the list of plugins */ |
||
29 | const KEY_PLUGINS = 'plugins'; |
||
30 | /** the config key for the list of controller namespaces */ |
||
31 | const KEY_NAMESPACES = 'namespaces'; |
||
32 | /** the config key for the list of controller folders */ |
||
33 | const KEY_FOLDERS = 'folders'; |
||
34 | /** the config key for the list of tasks */ |
||
35 | const KEY_TASKS = 'tasks'; |
||
36 | /** the config key for debug mode */ |
||
37 | const KEY_DEBUG = 'debug'; |
||
38 | |||
39 | // the internal config array |
||
40 | private $config; |
||
41 | |||
42 | /** |
||
43 | * Constructor for the class. |
||
44 | * @param mixed $config An array of config settings (or something that easily |
||
45 | * typecasts to an array like an stdClass). |
||
46 | */ |
||
47 | 10 | public function __construct($config) |
|
51 | |||
52 | /** |
||
53 | * Returns whether or not the given key exists in the config. |
||
54 | * @param string $key The key to be checked. |
||
55 | * @return Returns true if the key exists and false otherwise. |
||
56 | */ |
||
57 | 9 | public function offsetExists($key) |
|
61 | |||
62 | /** |
||
63 | * Returns the value associated with the key or null if no value exists. |
||
64 | * @param string $key The key to be fetched. |
||
65 | * @return Returns the value associated with the key or null if no value exists. |
||
66 | */ |
||
67 | 9 | public function offsetGet($key) |
|
71 | |||
72 | /** |
||
73 | * Sets the value associated with the given key. |
||
74 | * @param string $key The key to be used. |
||
75 | * @param mixed $value The value to be set. |
||
76 | * @return void |
||
77 | */ |
||
78 | 2 | public function offsetSet($key, $value) |
|
85 | |||
86 | /** |
||
87 | * Removes the value set to the given key. |
||
88 | * @param string $key The key to unset. |
||
89 | * @return void |
||
90 | */ |
||
91 | 1 | public function offsetUnset($key) |
|
95 | |||
96 | /** |
||
97 | * Returns the value associated with the given key. An optional default value |
||
98 | * can be provided and will be returned if no value is associated with the key. |
||
99 | * @param string $key The key to be used. |
||
100 | * @param mixed $defaultValue The default value to return if the key currently |
||
101 | * has no value associated with it. |
||
102 | * @return Returns the value associated with the key or the default value if |
||
103 | * no value is associated with the key. |
||
104 | */ |
||
105 | 9 | public function get($key, $defaultValue = null) |
|
109 | |||
110 | /** |
||
111 | * Sets the current value associated with the given key. |
||
112 | * @param string $key The key to be set. |
||
113 | * @param mixed $value The value to be set to the key. |
||
114 | * @return void |
||
115 | */ |
||
116 | 1 | public function set($key, $value) |
|
120 | |||
121 | /** |
||
122 | * Returns an array representation of the whole configuration. |
||
123 | * @return array An array representation of the whole configuration. |
||
124 | */ |
||
125 | 1 | public function toArray() |
|
129 | |||
130 | /** |
||
131 | * Returns whether or not we are in debug mode. |
||
132 | * @return boolean Returns true if the router is in debug mode and false |
||
133 | * otherwise. |
||
134 | */ |
||
135 | 1 | public function isDebug() |
|
139 | } |
||
140 |