Conditions | 4 |
Paths | 3 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | protected function loadSource(string $sourceId, bool $fromCache = true): string |
||
34 | { |
||
35 | if (! isset($this->sources[$sourceId])) { |
||
36 | throw new RuntimeError("Source `{$sourceId}` doesn't exist"); |
||
37 | } |
||
38 | |||
39 | $cachePath = $this->tempDir.'/'.$sourceId.'.rdfa'; |
||
40 | |||
41 | if ($fromCache && file_exists($cachePath)) { |
||
42 | return file_get_contents($cachePath); |
||
43 | } |
||
44 | |||
45 | $rdfa = file_get_contents($this->sources[$sourceId]); |
||
46 | |||
47 | file_put_contents($cachePath, $rdfa); |
||
48 | |||
49 | return $rdfa; |
||
50 | } |
||
51 | } |
||
52 |