Psr11::environment()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 14
rs 9.9666
1
<?php
2
3
namespace RestTemplate;
4
5
use ByJG\Config\Definition;
6
7
class Psr11
8
{
9
    private static $definition = null;
10
    private static $container = null;
11
12
    /**
13
     * @return \ByJG\Config\Container
14
     */
15
    public static function container()
16
    {
17
        if (is_null(self::$container)) {
18
            self::$container = self::environment()->build();
19
        }
20
21
        return self::$container;
22
    }
23
24
25
    /**
26
     * @return Definition
27
     */
28
    public static function environment()
29
    {
30
        if (is_null(self::$definition)) {
31
            self::$definition = (new Definition())
32
                ->addEnvironment('dev')
33
                ->addEnvironment('homolog')
34
                    ->inheritFrom('dev')
35
                ->addEnvironment('live')
36
                    ->inheritFrom('homolog')
37
                    ->inheritFrom('dev');
38
            // ->setCache($somePsr16Implementation); // This will cache the result;
39
        }
40
41
        return self::$definition;
42
    }
43
}
44