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) |
||
86 | |||
87 | /** |
||
88 | * Get a setting's default value. |
||
89 | * |
||
90 | * @param string $value |
||
91 | * |
||
92 | * @return mixed|null |
||
93 | */ |
||
94 | public function getDefault($value) |
||
100 | |||
101 | /** |
||
102 | * Return config array. |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | public function getAll() |
||
110 | |||
111 | /** |
||
112 | * Return the database directory path. |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | public function getDatabaseDirectory() |
||
120 | |||
121 | /** |
||
122 | * Return the migration directory path. |
||
123 | * |
||
124 | * @param string $path |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | public function getMigrationDirectory($path = '') |
||
132 | |||
133 | /** |
||
134 | * Return the factory directory path. |
||
135 | * |
||
136 | * @param string $path |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public function getFactoryDirectory($path = '') |
||
144 | |||
145 | /** |
||
146 | * Return the seeds directory path. |
||
147 | * |
||
148 | * @param string $path |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getSeedDirectory($path = '') |
||
156 | |||
157 | /** |
||
158 | * Make database directory structure if it doesn't exist. |
||
159 | */ |
||
160 | public function getAllDatabaseDirectories() |
||
169 | |||
170 | /** |
||
171 | * Return the config array. |
||
172 | * |
||
173 | * @return array |
||
174 | */ |
||
175 | public function toArray() |
||
179 | } |
||
180 |