Completed
Push — master ( b59592...c78116 )
by Faiz
01:47
created

Config   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 29
ccs 10
cts 12
cp 0.8333
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildConfig() 0 14 4
A get() 0 4 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
}