context   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A push() 0 4 1
A pop() 0 4 1
A peek() 0 9 2
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
 * Class context
16
 * A \arc\prototype\Prototype based dependency injection container
17
 * with stack functionality.
18
 *
19
 * @package arc
20
 * @requires \arc\prototype
21
 */
22
class context
23
{
24
    public static $context = null;
25
26
    /**
27
     * Adds/overrides a set of properties/methods in a new 'stack frame'
28
     * @param $params
29
     */
30
    public static function push($params)
31
    {
32
        self::$context = \arc\prototype::extend(self::$context, $params );
33
    }
34
35
    /**
36
     * Removes last addition/overrides from the container.
37
     */
38
    public static function pop()
39
    {
40
        self::$context = self::$context->prototype;
41
    }
42
43
    /**
44
     * Take a peek at earlier entries of the container.
45
     * @param int $level
46
     * @return null
47
     */
48
    public static function peek($level = 0)
49
    {
50
        $context = self::$context;
51
        for ($i = $level; $i >= 0; $i--) {
52
            $context = $context->prototype;
53
        }
54
55
        return $context;
56
    }
57
}
58
59
context::$context = \arc\prototype::create([
60
    'arcPath' => '/'
61
]);
62