Passed
Branch 0.3.0 (b16461)
by Anton
03:42
created

Factory::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 4
nc 3
nop 1
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])) return static::$cache[$table];
18
19
			# ------------------------
20
21
			return (static::$cache[$table] = new static::$classes[$table]);
22
		}
23
	}
24
}
25