Conditions | 4 |
Paths | 5 |
Total Lines | 21 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function read(string $path): array |
||
24 | { |
||
25 | try { |
||
26 | $filePath = $path; |
||
27 | |||
28 | do { |
||
29 | $json = file_get_contents($filePath); |
||
30 | $content = json_decode($json, true); |
||
31 | $filePath = $content[self::KEY_URL] ?? null; |
||
32 | } while (!empty($filePath)); |
||
33 | |||
34 | if (empty($content)) { |
||
35 | throw new DomainException(sprintf('No/invalid content found.')); |
||
36 | } |
||
37 | |||
38 | return $content; |
||
39 | } catch (Exception $exception) { |
||
40 | throw new ReadingFailed( |
||
41 | sprintf('Failed to read vocabulary at: `%s`', $path), |
||
42 | $exception->getCode(), |
||
43 | $exception |
||
44 | ); |
||
48 |