Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function createFromJson($json) |
||
30 | { |
||
31 | $content = json_decode($json, true); |
||
32 | if (!is_array($content)) { |
||
33 | throw new InvalidArgumentException('Invalid JSONFeed string'); |
||
34 | } |
||
35 | |||
36 | if (!isset($content['version'])) { |
||
37 | throw new RuntimeException('JSONFeed version is not defined'); |
||
38 | } |
||
39 | |||
40 | if (!isset($this->readers[$content['version']])) { |
||
41 | throw new RuntimeException(sprintf('No reader for version "%s"', $content['version'])); |
||
42 | } |
||
43 | |||
44 | return $this->readers[$content['version']]->readFromJson($json); |
||
45 | } |
||
46 | } |
||
47 |