DI::default()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Quick APIs of container (default)
4
 * User: moyo
5
 * Date: 11/10/2017
6
 * Time: 4:13 PM
7
 */
8
9
namespace Carno\Container;
10
11
/**
12
 * @see Container
13
 * @method static bool has(string $id)
14
 * @method static mixed get(string $id)
15
 * @method static mixed set(string $id, object $object)
16
 * @method static mixed object(string $class, mixed ...$args)
17
 */
18
final class DI
19
{
20
    /**
21
     * @var Container
22
     */
23
    private static $container = null;
24
25
    /**
26
     * @return Container
27
     */
28
    private static function default() : Container
29
    {
30
        return self::$container ?? self::$container = new Container();
31
    }
32
33
    /**
34
     * @param string $name
35
     * @param array $args
36
     * @return mixed
37
     */
38
    public static function __callStatic(string $name, array $args)
39
    {
40
        return self::default()->$name(...$args);
41
    }
42
}
43