Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function getMockData(string $file) : array |
||
19 | { |
||
20 | $fileInfo = $this->getFileInfo($file); |
||
21 | $mockFile = "{$fileInfo['dirname']}/mock.json"; |
||
22 | |||
23 | if (!file_exists($mockFile)) { |
||
24 | throw new \InvalidArgumentException('The mock.json must be at same level of php file.'); |
||
25 | } |
||
26 | |||
27 | $data = json_decode(file_get_contents($mockFile), true); |
||
28 | |||
29 | if (empty($data)) { |
||
30 | throw new \InvalidArgumentException('Invalid mock.json!'); |
||
31 | } |
||
32 | |||
33 | return $data; |
||
34 | } |
||
57 |