Passed
Push — main ( 0d5649...d7c64d )
by Breno
01:51
created

Singleton::__callStatic()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 10
rs 10
cc 2
nc 2
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace OniBus\Utility;
5
6
trait Singleton
7
{
8
    protected static $instance = null;
9
10
    public static function instance()
11
    {
12
        if (is_null(static::$instance)) {
13
            self::$instance = static::singleInstance();
14
        }
15
16
        return self::$instance;
17
    }
18
19
    abstract protected static function singleInstance();
20
21
    protected function __construct()
22
    {
23
    }
24
25
    private function __clone()
26
    {
27
    }
28
}
29