Di::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
/*
4
 *  @copyright (c) 2019 Mendel <[email protected]>
5
 *  @license see license.txt
6
 */
7
8
namespace drycart\di;
9
10
/**
11
 * Singleton/Container for Di
12
 *
13
 * @author mendel
14
 */
15
class Di
16
{
17
    private static $instance = null;
18
19
    public static function setInstance(?DiInterface $intance) : void
20
    {
21
        self::$instance = $intance;
22
    }
23
24
    public static function getInstance() : DiInterface
25
    {
26
        if (is_null(self::$instance)) {
27
            self::$instance = new Container();
28
        }
29
        return self::$instance;
30
    }
31
}
32