ConfigUtils   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 8 4
1
<?php
2
3
/**
4
 * This file is part of the Cubiche application.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Tools;
12
13
use Symfony\Component\Yaml\Yaml;
14
15
/**
16
 * ConfigUtils class.
17
 *
18
 * @author Ivannis Suárez Jérez <[email protected]>
19
 */
20
class ConfigUtils
21
{
22
    const CONFIG_FILE = 'quality.yml';
23
24
    /**
25
     * @var array
26
     */
27
    protected static $config = null;
28
29
    /**
30
     * @param string $task
31
     * @param array  $defaults
32
     *
33
     * @return array|mixed
34
     */
35
    public static function getConfig($task, array $defaults = array())
36
    {
37
        if (self::$config === null) {
38
            self::$config = file_exists(self::CONFIG_FILE) ? Yaml::parse(file_get_contents(self::CONFIG_FILE)) : [];
39
        }
40
41
        return isset(self::$config[$task]) ? self::$config[$task] : $defaults;
42
    }
43
}
44