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.

Issues (140)

app/Events/ButtonSubmitted.php (9 issues)

1
<?php
2
0 ignored issues
show
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\StaticPage\Events;
4
5
use BristolSU\Module\StaticPage\Models\ButtonClick;
6
use BristolSU\Module\StaticPage\Models\PageView;
7
use BristolSU\Support\Action\Contracts\TriggerableEvent;
8
use BristolSU\Support\ActivityInstance\Contracts\ActivityInstanceRepository;
9
use BristolSU\Support\ModuleInstance\Contracts\ModuleInstanceRepository;
10
11
class ButtonSubmitted implements TriggerableEvent
0 ignored issues
show
Missing doc comment for class ButtonSubmitted
Loading history...
12
{
13
14
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
15
     * @var ButtonClick
16
     */
17
    private $buttonClick;
0 ignored issues
show
Private member variable "buttonClick" must be prefixed with an underscore
Loading history...
18
19 5
    public function __construct(ButtonClick $buttonClick)
0 ignored issues
show
Missing doc comment for function __construct()
Loading history...
20
    {
21
22 5
        $this->buttonClick = $buttonClick;
23 5
    }
24
25
    /**
26
     * Register metadata about the fields the event supplies.
27
     *
28
     * For each field returned in getFields, pass in a label and a helptext.
29
     * e.g. [
30
     *      'user_id' => [
31
     *          'label' => 'User ID',
32
     *          'helptext' => 'The ID of the user who posted the comment.'
33
     *          ],
34
     *      ...
35
     * ]
36
     * @return array
0 ignored issues
show
There must be exactly one blank line before the tags in a doc comment
Loading history...
37
     */
38 1
    public static function getFieldMetaData(): array
39
    {
40
        return [
41
          'user_id' => [
42 1
            'label' => 'User ID',
43
            'helptext' => 'The ID of the user'
44
          ],
45
          'user_email' => [
46
            'label' => 'Email Address',
47
            'helptext' => 'Email Address of the user. May be empty.'
48
          ],
49
          'user_first_name' => [
50
            'label' => 'First Name',
51
            'helptext' => 'First Name of the user. May be empty.'
52
          ],
53
          'user_last_name' => [
54
            'label' => 'Last Name',
55
            'helptext' => 'Last Name of the user. May be empty.'
56
          ],
57
          'user_preferred_name' => [
58
            'label' => 'Preferred Name',
59
            'helptext' => 'Preferred Name of the user. May be empty.'
60
          ],
61
          'module_instance_id' => [
62
            'label' => 'Module Instance ID',
63
            'helptext' => 'ID of the module instance viewed'
64
          ],
65
          'module_instance_name' => [
66
            'label' => 'Module Instance Name',
67
            'helptext' => 'Name of the module instance viewed.'
68
          ],
69
          'activity_instance_id' => [
70
            'label' => 'Activity Instance ID',
71
            'helptext' => 'The id of the activity instance viewed.'
72
          ],
73
          'activity_instance_name' => [
74
            'label' => 'Activity Instance Name',
75
            'helptext' => 'The name of the activity instance viewed.'
76
          ],
77
          'clicked_at' => [
78
            'label' => 'Button Clicked At',
79
            'helptext' => 'The date and time the button was clicked at'
80
          ],
81
        ];
82
    }
83
84
    /**
85
     * Get the fields that the event registers.
86
     *
87
     * If the event has parameters which should be used in the framework, return them here.
88
     *
89
     * e.g. [
90
     *      'user_id' => 1,
91
     *      'comment_id' => 4,
92
     *      'post_id' => 3
93
     * ]
94
     * @return array
0 ignored issues
show
There must be exactly one blank line before the tags in a doc comment
Loading history...
95
     */
96 2
    public function getFields(): array
97
    {
98 2
        $moduleInstance = app(ModuleInstanceRepository::class)->getById($this->buttonClick->module_instance_id);
99 2
        $activityInstance = app(ActivityInstanceRepository::class)->getById($this->buttonClick->activity_instance_id);
100
        return [
101 2
          'user_id' => $this->buttonClick->user->id(),
102 2
          'user_email' => $this->buttonClick->user->data()->email(),
103 2
          'user_first_name' => $this->buttonClick->user->data()->firstName(),
104 2
          'user_last_name' => $this->buttonClick->user->data()->lastName(),
105 2
          'user_preferred_name' => $this->buttonClick->user->data()->preferredName(),
106 2
          'clicked_at' => $this->buttonClick->created_at->format('Y-m-d H:i:s'),
107 2
          'module_instance_id' => $moduleInstance->id,
0 ignored issues
show
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...
108 2
          'module_instance_name' => $moduleInstance->name,
0 ignored issues
show
Accessing name on the interface BristolSU\Support\Module...ontracts\ModuleInstance suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
109 2
          'activity_instance_id' => $activityInstance->id,
110 2
          'activity_instance_name' => $activityInstance->name,
111
        ];
112
    }
113
}
114