DownloadController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 12
c 1
b 1
f 0
dl 0
loc 19
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 17 1
1
<?php
2
3
namespace Djoudi\LaravelH5p\Http\Controllers;
4
5
use App\Http\Controllers\Controller;
0 ignored issues
show
Bug introduced by
The type App\Http\Controllers\Controller was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Djoudi\LaravelH5p\Events\H5pEvent;
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\App;
9
10
class DownloadController extends Controller
11
{
12
    public function __invoke(Request $request, $id)
13
    {
14
        $h5p = App::make('LaravelH5p');
15
        $core = $h5p::$core;
16
        $interface = $h5p::$interface;
17
18
        $content = $core->loadContent($id);
19
        $content['filtered'] = '';
20
        $params = $core->filterParameters($content);
0 ignored issues
show
Unused Code introduced by
The assignment to $params is dead and can be removed.
Loading history...
21
22
        return response()
23
            ->download($interface->_download_file, '', [
24
                'Content-Type'  => 'application/zip',
25
                'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
26
            ]);
27
28
        event(new H5pEvent('download', null, $content['id'], $content['title'], $content['library']['name'], $content['library']['majorVersion'], $content['library']['minorVersion']));
0 ignored issues
show
Unused Code introduced by
event(new Djoudi\Laravel...ary']['minorVersion'])) is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
29
    }
30
}
31