MslsRegistryInstance::instance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
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
}