SingletonTrait::singleton()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php 
2
3
namespace Vertex\Core\Traits;
4
5
trait SingletonTrait
6
{
7
	/**
8
	 * The instance of the class.
9
	 * 
10
	 * @var object
11
	 */
12
    protected static $instance;
13
  	
14
  	/**
15
  	 * Fetch the instance of the class.
16
  	 *
17
	 * @var mixed $parameters
18
  	 * @return object
19
  	 */
20
    public static function singleton(...$parameters)
21
    {
22
        if (!isset(self::$instance)) {
23
        	$class = __CLASS__;
24
            self::$instance = new $class(...$parameters);
25
        }
26
        return self::$instance;
27
    }
28
}