Creator::destroy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Traits;
4
5
trait Creator
6
{
7
    /**
8
     * Holds the only instance of me
9
     * @var mixed
10
     */
11
    protected static $singleton = null;
12
13
    public function destroy()
14
    {
15
        self::$singleton = null;
16
    }
17
18
    /**
19
     * Create the only instance of me and return it
20
     * @return mixed
21
     */
22
    public static function create()
23
    {
24
        if (self::$singleton === null) {
25
            $className = static::class;
26
            self::$singleton = new $className();
27
        }
28
        return self::$singleton;
29
    }
30
}
31