| Conditions | 4 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | 28 | public function getDialectClass(string $path): ADialect |
|
| 31 | { |
||
| 32 | 28 | if (!isset(static::$instances[$path])) { |
|
| 33 | try { |
||
| 34 | /** @var class-string $path */ |
||
| 35 | 5 | $reflect = new ReflectionClass($path); |
|
| 36 | 4 | $instance = $reflect->newInstance(); |
|
| 37 | 1 | } catch (ReflectionException $ex) { |
|
| 38 | 1 | throw new MapperException(sprintf('Wanted class *%s* not exists!', $path), $ex->getCode(), $ex); |
|
| 39 | } |
||
| 40 | 4 | if (!$instance instanceof ADialect) { |
|
| 41 | 1 | throw new MapperException(sprintf('Defined class *%s* is not instance of AMapper!', $path)); |
|
| 42 | } |
||
| 43 | 3 | static::$instances[$path] = $instance; |
|
| 44 | } |
||
| 45 | 26 | return static::$instances[$path]; |
|
| 46 | } |
||
| 48 |