| Conditions | 3 |
| Paths | 4 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 22 | public function getFormatClass(string $path): IFileFormat |
|
| 29 | { |
||
| 30 | try { |
||
| 31 | /** @var class-string $path */ |
||
| 32 | 22 | $reflect = new ReflectionClass($path); |
|
| 33 | 21 | $instance = $reflect->newInstance(); |
|
| 34 | 1 | } catch (ReflectionException $ex) { |
|
| 35 | 1 | throw new MapperException(sprintf('Wanted class *%s* not exists!', $path), $ex->getCode(), $ex); |
|
| 36 | } |
||
| 37 | 21 | if (!$instance instanceof IFileFormat) { |
|
| 38 | 1 | throw new MapperException(sprintf('Defined class *%s* is not instance of IFileFormat!', $path)); |
|
| 39 | } |
||
| 40 | 20 | return $instance; |
|
| 41 | } |
||
| 43 |