HelperInst::setMu()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 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