Completed
Push — master ( b59592...c78116 )
by Faiz
01:47
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 57
    private function buildConfig(array $config = [], $sapi = "")
15
    {
16 57
        if(strlen($sapi) == 0) $sapi = php_sapi_name();
17
18
        // Merge our config with user config
19 57
        $result = array_merge((include realpath(__DIR__ . '/../../config/quran.php')), $config);
20
21
        // If function storage_path is exist (laravel), we update the path to laravel's storage path
22 57
        if (function_exists('storage_path') && $sapi !== 'cli') {
23
            $result['storage_path'] = storage_path('app' . DIRECTORY_SEPARATOR . $result['storage_path']);
24
        }
25
26 57
        return $result;
27
    }
28
29 57
    public function get($val)
30
    {
31 57
        return $this->config[$val];
32
    }
33
}