MslsRegistryInstance   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A instance() 0 11 2
1
<?php
2
/**
3
 * MslsRegistryInstance
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 1.1
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * Class MslsRegistryInstance
12
 *
13
 * @package lloc\Msls
14
 */
15
class MslsRegistryInstance {
16
17
	/**
18
	 * Gets or creates an instance of the called class
19
	 *
20
	 * @return static
21
	 */
22
	public static function instance() {
23
		$class = get_called_class();
24
25
		if ( ! ( $obj = MslsRegistry::get_object( $class ) ) ) {
26
			$obj = new $class;
27
28
			MslsRegistry::set_object( $class, $obj );
29
		}
30
31
		return $obj;
32
	}
33
34
}