UtilsBase::instance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace JimmyOak\Utility;
4
5
abstract class UtilsBase
6
{
7
    protected function __construct()
8
    {
9
    }
10
11
    public static function instance()
12
    {
13
        static $instance = null;
14
15
        if ($instance === null) {
16
            $instance = new static();
17
        }
18
19
        return $instance;
20
    }
21
22
    public function __clone()
23
    {
24
        throw new \Exception('Singleton class, use instance() method');
25
    }
26
}
27