FactoryTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 1
cbo 0
dl 0
loc 22
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A instance() 0 8 2
A unsetInstance() 0 4 1
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