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.

HasClickedSubmit::isComplete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 1
nop 3
dl 0
loc 3
c 1
b 0
f 0
cc 1
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
namespace BristolSU\Module\StaticPage\CompletionConditions;
5
6
7
use BristolSU\Module\StaticPage\Models\ButtonClick;
8
use BristolSU\Module\StaticPage\Models\PageView;
9
use BristolSU\Support\ActivityInstance\ActivityInstance;
10
use BristolSU\Support\Completion\Contracts\CompletionCondition;
11
use BristolSU\Support\ModuleInstance\Contracts\ModuleInstance;
12
use FormSchema\Schema\Form;
13
14
class HasClickedSubmit extends CompletionCondition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class HasClickedSubmit
Loading history...
15
{
16
17
    /**
18
     * Is the condition fully complete?
19
     *
20
     * @param array $settings Settings of the completion condition
0 ignored issues
show
Coding Style introduced by
Expected 12 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 9 spaces after parameter name; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
21
     * @param ActivityInstance $activityInstance Activity instance to test
0 ignored issues
show
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
22
     * @param ModuleInstance $moduleInstance Module instance to test
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
23
     * @return bool If the condition is complete
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
24
     */
25
    public function isComplete($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): bool
26
    {
27
        return ButtonClick::forResource($activityInstance->id, $moduleInstance->id)->count() > 0;
0 ignored issues
show
Bug introduced by
Accessing id on the interface BristolSU\Support\Module...ontracts\ModuleInstance suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
28
    }
29
30
    public function percentage($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): int
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function percentage()
Loading history...
31
    {
32
        if($this->isComplete($settings, $activityInstance, $moduleInstance)) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
33
            return 100;
34
        }
35
        return 0;
36
    }
37
38
    /**
39
     * Options required by the completion condition.
40
     *
41
     * Any settings requested in here will be passed into the percentage or isComplete methods.
42
     *
43
     * @return Form
44
     * @throws \Exception
45
     */
46
    public function options(): Form
47
    {
48
        return \FormSchema\Generator\Form::make()->getSchema();
49
    }
50
51
    /**
52
     * A name for the completion condition
53
     *
54
     * @return string
55
     */
56
    public function name(): string
57
    {
58
        return 'Has clicked the submit button';
59
    }
60
61
    /**
62
     * A description of the completion condition
63
     *
64
     * @return string
65
     */
66
    public function description(): string
67
    {
68
        return 'Marked as complete when the user/group/role has clicked the submit button.';
69
    }
70
71
    /**
72
     * The alias of the completion condition
73
     *
74
     * @return string
75
     */
76
    public function alias(): string
77
    {
78
        return 'static_page_has_submitted';
79
    }
80
}