Conditions | 6 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
25 | 56 | public function parse($data): Jsonapi |
|
26 | { |
||
27 | 56 | if (! is_object($data)) { |
|
28 | 24 | throw new ValidationException(sprintf('Jsonapi MUST be an object, "%s" given.', gettype($data))); |
|
29 | } |
||
30 | 32 | if (property_exists($data, 'version') && ! is_string($data->version)) { |
|
31 | 24 | throw new ValidationException(sprintf('Jsonapi property "version" MUST be a string, "%s" given.', gettype($data->version))); |
|
32 | } |
||
33 | |||
34 | 8 | return new Jsonapi( |
|
35 | 8 | property_exists($data, 'version') ? $data->version : null, |
|
36 | 8 | property_exists($data, 'meta') ? $this->metaParser->parse($data->meta) : null |
|
37 | 4 | ); |
|
40 |