SingletonTrait::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Webino™ (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino for the canonical source repository
6
 * @copyright   Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoBaseLib\Util;
12
13
/**
14
 * Class SingletonTrait
15
 */
16
trait SingletonTrait
17
{
18
    /**
19
     * @var $this
20
     */
21
    protected static $instance;
22
23
    /**
24
     * @return $this
25
     */
26
    public static function getInstance()
27
    {
28
        if (null === static::$instance) {
29
            static::$instance = new static;
30
        }
31
        return static::$instance;
32
    }
33
}
34