FactoryTrait::instance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
4
namespace Beanie\Util;
5
6
7
trait FactoryTrait
8
{
9
    /** @var static */
10
    private static $instance;
11
12
    /**
13
     * @return static
14
     */
15 110
    public static function instance()
16
    {
17 110
        if (!isset(self::$instance)) {
18 6
            self::$instance = new static();
19 6
        }
20
21 110
        return self::$instance;
22
    }
23
24 5
    public static function unsetInstance()
25
    {
26 5
        self::$instance = null;
27 5
    }
28
}
29