Config::get()   B
last analyzed

Complexity

Conditions 6
Paths 3

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 11
rs 8.8571
cc 6
eloc 8
nc 3
nop 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: vikkio88
5
 * Date: 01/11/2015
6
 * Time: 21:22
7
 */
8
9
namespace App\Lib\Helpers;
10
11
12
/**
13
 * Class Config
14
 * @package App\Lib\Helpers
15
 */
16
class Config
17
{
18
    /**
19
     * @param $key
20
     * @param null $directory
21
     * @return null
22
     */
23
    public static function get($key, $directory = null)
24
    {
25
        $fileName = $directory . "config/";
26
        $exp = explode(".", $key);
27
        if (is_array($exp) && $exp[0] != null && $exp[1] != null && file_exists($fileName . $exp[0] . ".php")) {
28
            $conf = include($fileName . $exp[0] . ".php");
29
            $val = array_key_exists($exp[1], $conf) ? $conf[$exp[1]] : null;
30
            return $val;
31
        }
32
        return null;
33
    }
34
35
}