Passed
Push — main ( 302427...b5b644 )
by Yaroslav
14:44
created

DownloadExportController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 16
c 1
b 0
f 0
ccs 0
cts 9
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 1
1
<?php
2
3
namespace NovaExportConfiguration\Http\Controllers;
4
5
use Illuminate\Routing\Controller;
6
use Illuminate\Support\Facades\Storage;
7
use NovaExportConfiguration\Models\ExportStoredFile;
8
9
class DownloadExportController extends Controller
10
{
11
    public function __invoke(string $file): mixed
12
    {
13
        /** @var ExportStoredFile $csvFile */
14
        $csvFile = ExportStoredFile::query()
15
            ->where('path', $file)
16
            ->firstOrFail();
17
18
        $storage = Storage::disk($csvFile->disk);
0 ignored issues
show
Bug introduced by
The property disk does not seem to exist on NovaExportConfiguration\Models\ExportStoredFile. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
19
20
        abort_if(!$storage->exists($csvFile->path), 404);
0 ignored issues
show
Bug introduced by
The property path does not seem to exist on NovaExportConfiguration\Models\ExportStoredFile. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
21
22
        return $storage->download(
23
            $csvFile->path,
24
            preg_replace("/[^a-zA-Z0-9\_\-\.\s]/i", '_', $csvFile->name)
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on NovaExportConfiguration\Models\ExportStoredFile. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
25
        );
26
    }
27
}
28