Conditions | 3 |
Paths | 2 |
Total Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3.0175 |
Changes | 0 |
1 | <?php |
||
31 | 2 | public function convertFrom(string $data): AbstractDataProvider |
|
32 | { |
||
33 | 2 | $data = json_decode($data, true); |
|
34 | |||
35 | 2 | if (!isset($data['class']) || !isset($data['data'])) { |
|
36 | throw new ConverterException('Data have wrong format to convert (No class or data field)'); |
||
37 | } |
||
38 | |||
39 | 2 | $provider = $data['class']; |
|
40 | |||
41 | 2 | $provider = new $provider(); |
|
42 | 2 | $provider->fromArray($data['data']); |
|
43 | |||
44 | 2 | return $provider; |
|
45 | } |
||
46 | } |