1 | <?php |
||
5 | class Config |
||
6 | { |
||
7 | private $config; |
||
8 | |||
9 | public $configFile; |
||
10 | |||
11 | 93 | public function __construct(array $config = []) |
|
15 | |||
16 | /** |
||
17 | * Build a config array. Merge user defined config with our default config. |
||
18 | * |
||
19 | * @param array $config User defined config |
||
20 | * @return array New configuration array |
||
21 | */ |
||
22 | 93 | private function buildConfig(array $config = []) |
|
23 | { |
||
24 | 93 | $this->configFile = realpath(__DIR__ . '/../../config/quran.php'); |
|
25 | |||
26 | // Merge our config with user config |
||
27 | 93 | $result = array_replace_recursive((include $this->configFile), $config); |
|
28 | |||
29 | // If function storage_path is exist (laravel), we update the path to laravel's storage path |
||
30 | 93 | if (function_exists('storage_path') && php_sapi_name() !== 'cli') { |
|
31 | $result['storage_path'] = storage_path('app/' . $result['storage_path']); |
||
32 | } else { |
||
33 | 93 | $result['storage_path'] = realpath(__DIR__ . '/../..') . '/' . $result['storage_path']; |
|
34 | } |
||
35 | |||
36 | // Merge translation with custom translation variable |
||
37 | |||
38 | 93 | return $result; |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * Get the config variable. |
||
43 | * |
||
44 | * @param string $val Variable name |
||
45 | * @return array|string Variable value |
||
46 | */ |
||
47 | 123 | public function get($val) |
|
58 | |||
59 | /** |
||
60 | * Return all configurations. |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | 3 | public function all() |
|
68 | |||
69 | 3 | public function addTranslation($id) |
|
80 | } |
||
81 |