GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( ec7d81...f16a76 )
by Toby
08:53
created

FileController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 31
dl 0
loc 67
ccs 21
cts 35
cp 0.6
rs 10
c 1
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 13 1
A destroy() 0 10 1
A show() 0 5 1
A index() 0 5 1
A store() 0 23 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\UploadFile\Http\Controllers\AdminApi;
4
5
use BristolSU\Module\UploadFile\Events\DocumentDeleted;
6
use BristolSU\Module\UploadFile\Events\DocumentUpdated;
7
use BristolSU\Module\UploadFile\Events\DocumentUploaded;
8
use BristolSU\Module\UploadFile\Http\Controllers\Controller;
9
use BristolSU\Module\UploadFile\Http\Requests\AdminApi\FileController\StoreRequest;
10
use BristolSU\Module\UploadFile\Models\File;
11
use BristolSU\Support\Activity\Activity;
12
use BristolSU\Support\ActivityInstance\Contracts\ActivityInstanceResolver;
13
use BristolSU\Support\Authentication\Contracts\Authentication;
14
use BristolSU\Support\ModuleInstance\ModuleInstance;
15
use Illuminate\Auth\Access\AuthorizationException;
16
use Illuminate\Http\Request;
17
use Illuminate\Support\Arr;
18
19
class FileController extends Controller
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class FileController
Loading history...
20
{
21
22 3
    public function index()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function index()
Loading history...
23
    {
24 3
        $this->authorize('admin.file.index');
25
        
26 2
        return File::forModuleInstance()->with(['statuses', 'comments'])->get();
27
    }
28
29 3
    public function show(Activity $activity, ModuleInstance $moduleInstance, File $file)
0 ignored issues
show
Unused Code introduced by
The parameter $activity is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

29
    public function show(/** @scrutinizer ignore-unused */ Activity $activity, ModuleInstance $moduleInstance, File $file)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $moduleInstance is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

29
    public function show(Activity $activity, /** @scrutinizer ignore-unused */ ModuleInstance $moduleInstance, File $file)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Missing doc comment for function show()
Loading history...
30
    {
31 3
        $this->authorize('admin.file.index');
32
        
33 2
        return $file->load(['statuses', 'comments']);
34
    }
35
36 6
    public function store(StoreRequest $request, Authentication $authentication)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function store()
Loading history...
37
    {
38 6
        $fileMetadata = collect();
39
40 6
        foreach (Arr::wrap($request->file('file')) as $file) {
41
42 6
            $path = $file->store('uploadfile');
43
44 6
            $fileMetadata->push($tempFileMeta = File::create([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
45 6
                'title' => $request->input('title'),
46 6
                'description' => $request->input('description'),
47 6
                'filename' => $file->getClientOriginalName(),
48 6
                'mime' => $file->getClientMimeType(),
49 6
                'path' => $path,
50 6
                'size' => $file->getSize(),
51 6
                'uploaded_by' => $authentication->getUser()->id(),
52 6
                'activity_instance_id' => $request->input('activity_instance_id')
53
            ]));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
54
55 6
            event(new DocumentUploaded($tempFileMeta));
56
        }
57
58 6
        return $fileMetadata;
59
    }
60
61
    public function destroy(Request $request, Activity $activity, ModuleInstance $moduleInstance, File $file)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function destroy()
Loading history...
62
    {
63
        $this->authorize('admin.file.destroy');
64
65
        $file->delete();
66
        $file->refresh();
67
68
        event(new DocumentDeleted($file));
69
70
        return $file->refresh();
71
    }
72
73
    public function update(Request $request, Activity $activity, ModuleInstance $moduleInstance, File $file)
0 ignored issues
show
Unused Code introduced by
The parameter $activity is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

73
    public function update(Request $request, /** @scrutinizer ignore-unused */ Activity $activity, ModuleInstance $moduleInstance, File $file)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $moduleInstance is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

73
    public function update(Request $request, Activity $activity, /** @scrutinizer ignore-unused */ ModuleInstance $moduleInstance, File $file)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Missing doc comment for function update()
Loading history...
74
    {
75
        $this->authorize('admin.file.update');
76
77
        $file->title = $request->input('title', $file->title);
78
        $file->description = $request->input('description', $file->description);
79
        $file->activity_instance_id = $request->input('activity_instance_id', $file->activity_instance_id);
80
81
        $file->save();
82
83
        event(new DocumentUpdated($file));
84
85
        return $file;
86
    }
87
    
88
}