Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
10 | public function __invoke(FileContentsRequest $request) |
||
11 | { |
||
12 | $file = $request->get('file'); |
||
13 | |||
14 | abort_unless($file, Response::HTTP_UNPROCESSABLE_ENTITY); |
||
15 | |||
16 | $filePath = base_path($file); |
||
17 | |||
18 | $this->ensureFileExistInProject($filePath); |
||
19 | |||
20 | $contents = file_get_contents($filePath); |
||
21 | |||
22 | $this->ensureIsPhpFile($file, $contents); |
||
23 | |||
24 | $contents = explode("\n", $contents); |
||
25 | |||
26 | array_unshift($contents, 'dummy'); |
||
27 | unset($contents[0]); |
||
28 | |||
29 | return [ |
||
30 | 'code_snippet' => $contents, |
||
31 | ]; |
||
32 | } |
||
33 | } |
||
34 |