Completed
Push — master ( 998e37...ce7c33 )
by Faiz
01:51
created

Config::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace FaizShukri\Quran\Supports;
4
5
class Config
6
{
7
    private $config;
8
9 57
    public function __construct(array $config = [])
10
    {
11 57
        $this->config = $this->buildConfig($config);
12 57
    }
13
14
    /**
15
     * Build a config array. Merge user defined config with our default config.
16
     *
17
     * @param array $config User defined config
18
     *
19
     * @return array New configuration array
20
     */
21 57
    private function buildConfig(array $config = [])
22
    {
23
        // Merge our config with user config
24 57
        $result = array_merge((include realpath(__DIR__ . '/../../config/quran.php')), $config);
25
26
        // If function storage_path is exist (laravel), we update the path to laravel's storage path
27 57
        if (function_exists('storage_path') && php_sapi_name() !== 'cli')
28 57
            $result['storage_path'] = storage_path('app' . DIRECTORY_SEPARATOR . $result['storage_path']);
29
30 57
        return $result;
31
    }
32
33
    /**
34
     * Get the config variable
35
     *
36
     * @param string $val Variable name
37
     *
38
     * @return mixed Variable value
39
     */
40 57
    public function get($val)
41
    {
42 57
        return $this->config[$val];
43
    }
44
}