SingletonTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A singleton() 0 8 2
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
}