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.

DocumentUpdated::getFieldMetaData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 62
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 46
nc 1
nop 0
dl 0
loc 62
ccs 2
cts 2
cp 1
crap 1
rs 9.1781
c 1
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\UploadFile\Events;
4
5
use BristolSU\Module\UploadFile\Models\File;
6
use BristolSU\Support\Action\Contracts\TriggerableEvent;
7
8
class DocumentUpdated implements TriggerableEvent
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class DocumentUpdated
Loading history...
9
{
10
11
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
12
     * @var File
13
     */
14
    public $file;
15
16 14
    public function __construct(File $file)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
17
    {
18 14
        $this->file = $file;
19 14
    }
20
21
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
22
     * @inheritDoc
23
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
24 2
    public function getFields(): array
25
    {
26
        return [
27 2
            'file_id' => $this->file->id,
28 2
            'title' => $this->file->title,
29 2
            'description' => $this->file->description,
30 2
            'filename' => $this->file->filename,
31 2
            'mime' => $this->file->mime,
32 2
            'size' => $this->file->size,
33 2
            'uploaded_by_id' => $this->file->uploaded_by->id(),
0 ignored issues
show
Bug introduced by
The method id() does not exist on integer. ( Ignorable by Annotation )

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

33
            'uploaded_by_id' => $this->file->uploaded_by->/** @scrutinizer ignore-call */ id(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34 2
            'uploaded_by_email' => $this->file->uploaded_by->data()->email(),
35 2
            'uploaded_by_first_name' => $this->file->uploaded_by->data()->firstName(),
36 2
            'uploaded_by_last_name' => $this->file->uploaded_by->data()->lastName(),
37 2
            'uploaded_by_preferred_name' => $this->file->uploaded_by->data()->preferredName(),
38 2
            'module_instance_id' => $this->file->module_instance_id,
39 2
            'activity_instance_id' => $this->file->activity_instance_id,
40 2
            'uploaded_at' => $this->file->created_at->format('Y-m-d H:i:s'),
41 2
            'updated_at' => $this->file->updated_at->format('Y-m-d H:i:s'),
42
        ];
43
    }
44
45
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
46
     * @inheritDoc
47
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
48 1
    public static function getFieldMetaData(): array
49
    {
50
        return [
51
            'file_id' => [
52 1
                'label' => 'File ID',
53
                'helptext' => 'The ID of the file'
54
            ],
55
            'title' => [
56
                'label' => 'Title',
57
                'helptext' => 'The title given to the document when uploaded',
58
            ],
59
            'description' => [
60
                'label' => 'Description',
61
                'helptext' => 'A description of the file'
62
            ],
63
            'filename' => [
64
                'label' => 'Filename',
65
                'helptext' => 'The original filename of the document'
66
            ],
67
            'mime' => [
68
                'label' => 'Mimetype',
69
                'helptext' => 'The mime type of the file'
70
            ],
71
            'size' => [
72
                'label' => 'File Size',
73
                'helptext' => 'The size of the file in bytes'
74
            ],
75
            'uploaded_by_id' => [
76
                'label' => 'User ID',
77
                'helptext' => 'ID of the user who uploaded the file'
78
            ],
79
            'uploaded_by_email' => [
80
                'label' => 'User Email',
81
                'helptext' => 'Email of the user who uploaded the file'
82
            ],
83
            'uploaded_by_first_name' => [
84
                'label' => 'User First Name',
85
                'helptext' => 'First Name of the user who uploaded the file'
86
            ],
87
            'uploaded_by_last_name' => [
88
                'label' => 'User Last Name',
89
                'helptext' => 'Last Name of the user who uploaded the file'
90
            ],
91
            'uploaded_by_preferred_name' => [
92
                'label' => 'User Preferred Name',
93
                'helptext' => 'Preferred Name of the user who uploaded the file'
94
            ],
95
            'module_instance_id' => [
96
                'label' => 'Module Instance ID',
97
                'helptext' => 'ID of the module instance the file was uploaded to'
98
            ],
99
            'activity_instance_id' => [
100
                'label' => 'Activity Instance ID',
101
                'helptext' => 'ID of the activity instance that uploaded the file'
102
            ],
103
            'uploaded_at' => [
104
                'label' => 'Uploaded At',
105
                'helptext' => 'Time and date the file was uploaded at'
106
            ],
107
            'updated_at' => [
108
                'label' => 'Updated At',
109
                'helptext' => 'Time and date the file was last updated'
110
            ]
111
        ];
112
    }
113
}