| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | 5 | public function createFromArray(array $data): JobInterface |
|
| 13 | { |
||
| 14 | 5 | if (!isset($data['class'], $data['data'])) { |
|
| 15 | 1 | throw new InvalidArgumentException('Data does not contain required class key'); |
|
| 16 | } |
||
| 17 | |||
| 18 | 4 | if (!class_exists($data['class'])) { |
|
| 19 | 1 | throw new InvalidArgumentException("Unknown class '{$data['class']}' given"); |
|
| 20 | } |
||
| 21 | |||
| 22 | 3 | if (!is_subclass_of($data['class'], JobInterface::class)) { |
|
| 23 | 1 | throw new InvalidArgumentException("Class '{$data['class']}' does not implement JobInterface"); |
|
| 24 | } |
||
| 25 | |||
| 26 | 2 | return $data['class']::fromArray($data['data']); |
|
| 27 | } |
||
| 47 |