Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
38 | 27 | public function create(string $className) |
|
39 | { |
||
40 | 27 | if (array_key_exists($className, $this->cache)) { |
|
41 | 11 | return $this->cache[$className]; |
|
42 | } |
||
43 | |||
44 | 27 | if (!class_exists($className)) { |
|
45 | 1 | throw new RuntimeException("Mapper not found. Attempted to load '{$className}'."); |
|
46 | } |
||
47 | |||
48 | 26 | $instance = new $className($this->connection, $this->table); |
|
49 | 26 | $this->cache[$className] = $instance; |
|
50 | |||
51 | 26 | return $instance; |
|
52 | } |
||
55 |