Creator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 2
A destroy() 0 3 1
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