1 | <?php |
||
5 | class Config |
||
6 | { |
||
7 | /** |
||
8 | * Instance of self. |
||
9 | * |
||
10 | * @var Config |
||
11 | */ |
||
12 | private static $instance; |
||
13 | |||
14 | /** |
||
15 | * Yarak config array. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $configArray; |
||
20 | |||
21 | /** |
||
22 | * Default setting values. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | const DEFAULTS = [ |
||
27 | 'migratorType' => 'fileDate', |
||
28 | 'migrationRepository' => 'database', |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * Private constructor. |
||
33 | */ |
||
34 | private function __construct(array $configArray) |
||
38 | |||
39 | /** |
||
40 | * Get instance of self with config array set. |
||
41 | * |
||
42 | * @param array $configArray |
||
43 | * |
||
44 | * @return Config |
||
45 | */ |
||
46 | public static function getInstance(array $configArray = []) |
||
60 | |||
61 | /** |
||
62 | * Get a value from the config array. |
||
63 | * |
||
64 | * @param string|array $value |
||
65 | * |
||
66 | * @return mixed |
||
67 | */ |
||
68 | public function get($value) |
||
84 | |||
85 | /** |
||
86 | * Return true if config array has given value. |
||
87 | * |
||
88 | * @param mixed $value |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function has($value) |
||
100 | |||
101 | /** |
||
102 | * Get a setting's default value. |
||
103 | * |
||
104 | * @param string $value |
||
105 | * |
||
106 | * @return mixed|null |
||
107 | */ |
||
108 | public function getDefault($value) |
||
114 | |||
115 | /** |
||
116 | * Return config array. |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | public function getAll() |
||
124 | |||
125 | /** |
||
126 | * Set an item in the config. |
||
127 | * |
||
128 | * @param mixed $keys |
||
129 | * @param mixed $value |
||
130 | */ |
||
131 | public function set($keys, $value) |
||
143 | |||
144 | /** |
||
145 | * Remove an item from the config. |
||
146 | * |
||
147 | * @param mixed $keys |
||
148 | */ |
||
149 | public function remove($keys) |
||
163 | |||
164 | /** |
||
165 | * Return the database directory path. |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getDatabaseDirectory() |
||
173 | |||
174 | /** |
||
175 | * Return the migration directory path. |
||
176 | * |
||
177 | * @param string $path |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | public function getMigrationDirectory($path = '') |
||
185 | |||
186 | /** |
||
187 | * Return the factory directory path. |
||
188 | * |
||
189 | * @param string $path |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | public function getFactoryDirectory($path = '') |
||
197 | |||
198 | /** |
||
199 | * Return the seeds directory path. |
||
200 | * |
||
201 | * @param string $path |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | public function getSeedDirectory($path = '') |
||
209 | |||
210 | /** |
||
211 | * Make database directory structure if it doesn't exist. |
||
212 | */ |
||
213 | public function getAllDatabaseDirectories() |
||
222 | |||
223 | /** |
||
224 | * Get the commands directory path. |
||
225 | * |
||
226 | * @param string $path |
||
227 | * |
||
228 | * @return string |
||
229 | */ |
||
230 | public function getCommandsDirectory($path = '') |
||
236 | |||
237 | /** |
||
238 | * Return the config array. |
||
239 | * |
||
240 | * @return array |
||
241 | */ |
||
242 | public function toArray() |
||
246 | |||
247 | /** |
||
248 | * Add a final slash to a path if it doesn't exist. |
||
249 | * |
||
250 | * @param string $path |
||
251 | * |
||
252 | * @return string |
||
253 | */ |
||
254 | protected function addFinalSlash($path) |
||
262 | |||
263 | /** |
||
264 | * Make a variable an array if not one already. |
||
265 | * |
||
266 | * @param mixed $value |
||
267 | * |
||
268 | * @return array |
||
269 | */ |
||
270 | protected function makeArray($value) |
||
278 | } |
||
279 |