Passed
Push — main ( db9dfd...e1c759 )
by Breno
01:47
created

Singleton::__clone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

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