HelperInst   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A inst() 0 8 2
A setMu() 0 5 1
A mu() 0 3 1
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Traits;
4
5
use Sunnysideup\UpgradeToSilverstripe4\ModuleUpgrader;
6
7
trait HelperInst
8
{
9
    protected static $inst = null;
10
11
    protected $myMu = null;
12
13
    public static function inst($mu)
14
    {
15
        if (self::$inst === null) {
16
            $className = static::class;
17
            self::$inst = new $className();
18
            self::$inst->setMu($mu);
19
        }
20
        return self::$inst;
21
    }
22
23
    /**
24
     * @return self
25
     */
26
    protected function setMu(ModuleUpgrader $mu)
27
    {
28
        $this->myMu = $mu;
29
30
        return $this;
31
    }
32
33
    protected function mu(): ModuleUpgrader
34
    {
35
        return $this->myMu;
36
    }
37
}
38