config   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 61.11%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 36
ccs 11
cts 18
cp 0.6111
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A acquire() 0 4 1
A configure() 0 4 1
A cd() 0 4 1
A getConfiguration() 0 9 2
A reset() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the Ariadne Component Library.
5
 *
6
 * (c) Muze <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace arc;
13
14
/**
15
 * @requires \arc\path
16
 * @requires \arc\tree
17
 * @requires \arc\context
18
*/
19
class config
20
{
21 6
    public static function getConfiguration()
22
    {
23 6
        $context = \arc\context::$context;
24 6
        if (!$context->arcConfig) {
25 2
            $context->arcConfig = new config\Configuration( \arc\tree::expand()->cd( $context->arcPath ) );
26
        }
27
28 6
        return $context->arcConfig;
29
    }
30
31 2
    public static function acquire($name, $path = null, $root = '/')
32
    {
33 2
        return self::getConfiguration()->acquire( $name, $path, $root );
34
    }
35
36 2
    public static function configure($name, $value)
37
    {
38 2
        return self::getConfiguration()->configure( $name, $value );
39
    }
40
41 4
    public static function cd($path)
42
    {
43 4
        return self::getConfiguration()->cd( $path );
44
    }
45
46
    public static function reset($config = null) {
47
        $context = \arc\context::$context;
48
        $config = new \arc\config\Configuration( 
49
            \arc\tree\expand($config)
50
            ->cd( $context->arcPath ) 
51
        );
52
        $context->push( [ 'arcConfig' => $config ] );
53
    }
54
}
55