Conditions | 1 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | 1 | public function __invoke(string $file): mixed |
|
12 | { |
||
13 | /** @var ExportStoredFile $csvFile */ |
||
14 | 1 | $csvFile = ExportStoredFile::query() |
|
15 | 1 | ->where('path', $file) |
|
16 | 1 | ->firstOrFail(); |
|
17 | |||
18 | 1 | $storage = Storage::disk($csvFile->disk); |
|
19 | |||
20 | 1 | abort_if(!$storage->exists($csvFile->path), 404); |
|
21 | |||
22 | 1 | return $storage->download( |
|
23 | 1 | $csvFile->path, |
|
24 | 1 | preg_replace("/[^a-zA-Z0-9\_\-\.\s]/i", '_', $csvFile->name) |
|
25 | 1 | ); |
|
28 |