DownloadsController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A download() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Http\Controllers;
6
7
use Symfony\Component\HttpFoundation\BinaryFileResponse;
8
9
class DownloadsController extends Controller
10
{
11
    /**
12
     * Download a file.
13
     *
14
     * @param string $fileName
15
     *
16
     * @return BinaryFileResponse
17
     */
18
    public function download(string $fileName)
19
    {
20
        $filePath = public_path('files/'.$fileName);
21
22
        if (!file_exists($filePath)) {
23
            abort(404, 'File not found.');
24
        }
25
26
        return response()->download($filePath);
27
    }
28
}
29