Factory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 5
cts 10
cp 0.5
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromFiles() 0 7 2
A fromFile() 0 8 1
1
<?php
2
3
namespace Nip\Config;
4
5
use Nip\Config\Loaders\FileLoader;
6
7
/**
8
 * Class Factory
9
 * @package Nip\Config
10
 */
11
class Factory
12
{
13
    /**
14
     * @param Config $repository
15
     * @param $files
16
     */
17
    public static function fromFiles(Config $repository, $files)
18
    {
19
        foreach ($files as $key => $path) {
20
            $data = self::fromFile($path, false);
21
            $repository->set($key, $data);
22
        }
23
    }
24
25
    /**
26
     * @param $filename
27
     * @param bool $returnConfigObject
28
     * @param bool $useIncludePath
29
     * @return mixed|Config
30
     * @throws Exception\RuntimeException
31
     */
32 1
    public static function fromFile($filename, $returnConfigObject = false, $useIncludePath = false)
33
    {
34 1
        $loader = new FileLoader($filename);
35 1
        $loader->setUseIncludePath($useIncludePath);
36 1
        $loader->setReturnConfigObject($returnConfigObject);
37
38 1
        return $loader->getResult();
39
    }
40
}
41