Conditions | 3 |
Paths | 3 |
Total Lines | 11 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
22 | public function hydrate(array $data, string $class) : Message |
||
23 | { |
||
24 | if (empty($data) === true) { |
||
25 | throw new \ErrorException('Data is empty'); |
||
26 | } |
||
27 | |||
28 | if (is_subclass_of($class, DataInterface::class) === false) { |
||
29 | throw new \ErrorException('class is not implemented from DataInterface'); |
||
30 | } |
||
31 | |||
32 | return call_user_func($class . '::create', $data); |
||
33 | } |
||
34 | } |