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.

ButtonController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 35
c 2
b 0
f 0
rs 10
ccs 16
cts 18
cp 0.8889
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A destroy() 0 12 3
A store() 0 11 1
A index() 0 5 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\StaticPage\Http\Controllers\Api\Participant;
4
5
use BristolSU\Module\StaticPage\Events\ButtonSubmitted;
6
use BristolSU\Module\StaticPage\Events\ButtonUnsubmitted;
7
use BristolSU\Module\StaticPage\Http\Controllers\Controller;
8
use BristolSU\Module\StaticPage\Models\ButtonClick;
9
use BristolSU\Support\Activity\Activity;
10
use BristolSU\Support\ActivityInstance\Contracts\ActivityInstanceResolver;
11
use BristolSU\Support\Authentication\Contracts\Authentication;
12
use BristolSU\Support\ModuleInstance\ModuleInstance;
13
use Illuminate\Auth\Access\AuthorizationException;
14
use Illuminate\Http\Response;
15
use Illuminate\Validation\ValidationException;
16
17
class ButtonController extends Controller
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ButtonController
Loading history...
18
{
19
20 3
    public function store(Authentication $authentication)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function store()
Loading history...
21
    {
22 3
        $this->authorize('click-button');
23
24 3
        $buttonClick = ButtonClick::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...
25 3
          'clicked_by' => $authentication->getUser()->id()
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 10.
Loading history...
26
        ]);
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...
27
28 3
        event(new ButtonSubmitted($buttonClick));
29
30 3
        return $buttonClick;
31
    }
32
33 2
    public function index()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function index()
Loading history...
34
    {
35 2
        $this->authorize('view-page');
36
37 2
        return ButtonClick::forResource()->get();
38
    }
39
40 5
    public function destroy(Activity $activity, ModuleInstance $moduleInstance, ButtonClick $buttonClick, ActivityInstanceResolver  $activityInstanceResolver)
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

40
    public function destroy(/** @scrutinizer ignore-unused */ Activity $activity, ModuleInstance $moduleInstance, ButtonClick $buttonClick, ActivityInstanceResolver  $activityInstanceResolver)

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

40
    public function destroy(Activity $activity, /** @scrutinizer ignore-unused */ ModuleInstance $moduleInstance, ButtonClick $buttonClick, ActivityInstanceResolver  $activityInstanceResolver)

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 destroy()
Loading history...
41
    {
42 5
        $this->authorize('delete-button-click');
43 4
        if($activityInstanceResolver->getActivityInstance()->id !== (int) $buttonClick->activity_instance_id) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
44 1
            throw new AuthorizationException('The button click does not belong to your activity instance');
45
        }
46 3
        if($buttonClick->delete()) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
47 3
            event(new ButtonUnsubmitted($buttonClick));
48 3
            return Response::create('', Response::HTTP_NO_CONTENT);
49
        } else {
50
            throw ValidationException::withMessages([
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...
51
              'button' => ['Could not delete the button click']
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 16 spaces, but found 14.
Loading history...
52
            ]);
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...
53
        }
54
    }
55
56
}
57