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