Passed
Push — master ( 730195...f62b36 )
by Afshin
03:29
created

Config::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 1
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: afshin
5
 * Date: 11/16/17
6
 * Time: 12:02 PM
7
 */
8
9
namespace Core;
10
11
class Config {
12
13
    public static function get($key,$default = null){
14
        $path = __APP_ROOT__ . '/config/'.$key[0].'.php';
15
        $result = include_once $path;
16
        foreach (explode('.' , $key) as $segment) {
17
            if(isset($result[$segment]))
18
                $result = $result[$segment];
19
            else
20
                $result = $default;
21
        }
22
        return $result;
23
    }
24
}