Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | public function deserialize(String $data) |
||
17 | { |
||
18 | $data = json_decode($data->toNative(), true); |
||
19 | |||
20 | if (null === $data) { |
||
21 | throw new NotWellFormedException('Invalid JSON'); |
||
22 | } |
||
23 | |||
24 | if (!isset($data['@id'])) { |
||
25 | throw new MissingValueException('Missing property "@id".'); |
||
26 | } |
||
27 | if (!isset($data['@type'])) { |
||
28 | throw new MissingValueException('Missing property "@type".'); |
||
29 | } |
||
30 | |||
31 | return new IriOfferIdentifier( |
||
32 | $data['@id'], |
||
33 | OfferType::fromNative($data['@type']) |
||
34 | ); |
||
35 | } |
||
36 | } |
||
37 |