Passed
Pull Request — master (#10)
by Anton
07:57 queued 04:02
created

Factory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 10 3
1
<?php
2
3
namespace Modules\Entitizer\Utils {
4
5
	use Exception;
6
7
	abstract class Factory {
8
9
		protected static $error_message = '', $cache = [], $classes = [];
10
11
		# Get class instance
12
13
		public static function get(string $table) {
14
15
			if (!isset(static::$classes[$table])) throw new Exception\General(static::$error_message);
16
17
			if (!isset(static::$cache[$table])) static::$cache[$table] = new static::$classes[$table];
18
19
			# ------------------------
20
21
			return static::$cache[$table];
22
		}
23
	}
24
}
25