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 ( 13526a...f52031 )
by Toby
14:25 queued 11s
created

ModuleServiceProvider::namespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\UploadFile;
4
5
use BristolSU\Module\UploadFile\CompletionConditions\NumberOfDocumentsSubmitted;
6
use BristolSU\Module\UploadFile\CompletionConditions\NumberOfDocumentsWithStatus;
7
use BristolSU\Module\UploadFile\Events\CommentCreated;
8
use BristolSU\Module\UploadFile\Events\CommentDeleted;
9
use BristolSU\Module\UploadFile\Events\CommentUpdated;
10
use BristolSU\Module\UploadFile\Events\DocumentDeleted;
11
use BristolSU\Module\UploadFile\Events\DocumentUpdated;
12
use BristolSU\Module\UploadFile\Events\DocumentUploaded;
13
use BristolSU\Module\UploadFile\Events\StatusChanged;
14
use BristolSU\Module\UploadFile\Fields\TagList;
15
use BristolSU\Module\UploadFile\Models\Comment;
16
use BristolSU\Module\UploadFile\Models\File;
17
use BristolSU\Module\UploadFile\Models\FileStatus;
18
use BristolSU\Support\Completion\Contracts\CompletionConditionManager;
19
use BristolSU\Support\Module\ModuleServiceProvider as ServiceProvider;
20
use BristolSU\Support\ModuleInstance\ModuleInstance;
21
use FormSchema\Generator\Field;
22
use FormSchema\Generator\Form as FormGenerator;
23
use FormSchema\Generator\Group;
24
use FormSchema\Schema\Form;
25
use Illuminate\Database\Eloquent\ModelNotFoundException;
26
use Illuminate\Support\Facades\Route;
27
28
class ModuleServiceProvider extends ServiceProvider
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ModuleServiceProvider
Loading history...
29
{
30
31
    protected $permissions = [
32
        // ##### Web #####
33
        'view-page' => [
34
            'name' => 'View Participant Page',
35
            'description' => 'View the main page of the module.',
36
            'admin' => false
37
        ],
38
        'admin.view-page' => [
39
            'name' => 'View Admin Page',
40
            'description' => 'View the administrator page of the module.',
41
            'admin' => true
42
        ],
43
        
44
        // ##### Api #####
45
        // Files
46
        'file.store' => [
47
            'name' => 'Upload a new file',
48
            'description' => 'Allow the ability to upload a file.',
49
            'admin' => false
50
        ],
51
        'file.download' => [
52
            'name' => 'Download a file',
53
            'description' => 'Allow the user to download a file',
54
            'admin' => false
55
        ],
56
        'file.index' => [
57
            'name' => 'See files',
58
            'description' => 'Allow the user to view files',
59
            'admin' => false
60
        ],
61
        'file.destroy' => [
62
            'name' => 'Delete files',
63
            'description' => 'Allow the user to delete files',
64
            'admin' => false
65
        ],
66
        'file.update' => [
67
            'name' => 'Edit files',
68
            'description' => 'Allow the user to edit files',
69
            'admin' => false
70
        ],
71
        // Comments
72
        'comment.index' => [
73
            'name' => 'See comments',
74
            'description' => 'Allow the user to see comments',
75
            'admin' => false
76
        ],
77
        'comment.store' => [
78
            'name' => 'Comment',
79
            'description' => 'Allow the user to comment in files',
80
            'admin' => false
81
        ],
82
        'comment.destroy' => [
83
            'name' => 'Delete a Comment',
84
            'description' => 'Allow the user to delete a comment.',
85
            'admin' => false
86
        ],
87
        'comment.update' => [
88
            'name' => 'Update a Comment',
89
            'description' => 'Allow the user to update a comment.',
90
            'admin' => false
91
        ],
92
        
93
        // Files
94
        'admin.file.index' => [
95
            'name' => 'View all files',
96
            'description' => 'Allow the user to view all uploaded files',
97
            'admin' => true
98
        ],
99
        'admin.file.store' => [
100
            'name' => 'Upload a new file',
101
            'description' => 'Allow the ability to upload a file on behalf of a user.',
102
            'admin' => true
103
        ],
104
        'admin.file.destroy' => [
105
            'name' => 'Delete a file',
106
            'description' => 'Allow the user to delete any uploaded file',
107
            'admin' => true
108
        ],
109
        'admin.file.update' => [
110
            'name' => 'Update a File',
111
            'description' => 'Allow the user to update any file name/description or reassign the file.',
112
            'admin' => true
113
        ],
114
        'admin.file.download' => [
115
            'name' => 'Download files',
116
            'description' => 'Allow the user to download any uploaded files',
117
            'admin' => true
118
        ],
119
        // Statuses
120
        'admin.status.create' => [
121
            'name' => 'Change document status',
122
            'description' => 'Allow the user to change the status of any file',
123
            'admin' => true
124
        ],
125
        // Comments
126
        'admin.comment.index' => [
127
            'name' => 'See comments',
128
            'description' => 'Allow the admin to see comments',
129
            'admin' => true
130
        ],
131
        'admin.comment.store' => [
132
            'name' => 'Comment',
133
            'description' => 'Allow the admin to comment in files',
134
            'admin' => true
135
        ],
136
        'admin.comment.destroy' => [
137
            'name' => 'Delete a Comment',
138
            'description' => 'Allow the admin to delete a comment.',
139
            'admin' => true
140
        ],
141
        'admin.comment.update' => [
142
            'name' => 'Update a Comment',
143
            'description' => 'Allow the admin to update a comment.',
144
            'admin' => true
145
        ],
146
    ];
147
148
    protected $events = [
149
        CommentCreated::class => [
150
            'name' => 'Comment Left',
151
            'description' => 'When a comment has been left'
152
        ],
153
        CommentDeleted::class => [
154
            'name' => 'Comment Deleted',
155
            'description' => 'When a comment has been deleted'
156
        ],
157
        CommentUpdated::class => [
158
            'name' => 'Comment Updated',
159
            'description' => 'When a comment has been updated'
160
        ],
161
        DocumentDeleted::class => [
162
            'name' => 'Document Deleted',
163
            'description' => 'When a document is deleted'
164
        ],
165
        DocumentUpdated::class => [
166
            'name' => 'Document Updated',
167
            'description' => 'When a document is updated'
168
        ],
169
        DocumentUploaded::class => [
170
            'name' => 'Document Uploaded',
171
            'description' => 'When a document is uploaded'
172
        ],
173
        StatusChanged::class => [
174
            'name' => 'Status Changed',
175
            'description' => 'When the status of a document is changed'
176
        ]
177
    ];
178
    
179
    protected $commands = [
180
        
181
    ];
182
    
183 175
    public function alias(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function alias()
Loading history...
184
    {
185 175
        return 'uploadfile';
186
    }
187
188 175
    public function namespace()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function namespace()
Loading history...
189
    {
190 175
        return '\BristolSU\Module\UploadFile\Http\Controllers';
191
    }
192
    
193 175
    public function baseDirectory()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function baseDirectory()
Loading history...
194
    {
195 175
        return __DIR__ . '/..';
196
    }
197
198 175
    public function register()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function register()
Loading history...
199
    {
200 175
        parent::register(); // TODO: Change the autogenerated stub
201 175
    }
202
203 175
    public function boot()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function boot()
Loading history...
204
    {
205 175
        parent::boot();
206
        
207 175
        $this->registerGlobalScript('modules/uploadfile/js/components.js');
208
        
209 175
        $this->app->make(CompletionConditionManager::class)->register(
210 175
            $this->alias(), 'number_of_files_submitted', NumberOfDocumentsSubmitted::class
211
        );
212 175
        $this->app->make(CompletionConditionManager::class)->register(
213 175
            $this->alias(), 'number_of_files_submitted_with_status', NumberOfDocumentsWithStatus::class
214
        );
215
        
216
        Route::bind('uploadfile_file', function($id) {
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...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
217 67
            $file = File::findOrFail($id);
218 61
            if(request()->route('module_instance_slug') && (int) $file->module_instance_id === request()->route('module_instance_slug')->id()) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
219 61
                return $file;
220
            }
221
            throw (new ModelNotFoundException)->setModel(File::class);
222 175
        });
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...
223
        
224
        Route::bind('uploadfile_file_status', function($id) {
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...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
225
            $fileStatus = FileStatus::findOrFail($id);
226
            if(request()->route('module_instance_slug') && (int) $fileStatus->file->module_instance_id === request()->route('module_instance_slug')->id()) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
227
                return $fileStatus;
228
            }
229
            throw (new ModelNotFoundException)->setModel(FileStatus::class);
230 175
        });
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...
231
        
232
        Route::bind('uploadfile_comment', function($id) {
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...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
233 22
            $comment = Comment::findOrFail($id);
234 22
            if(request()->route('module_instance_slug') && (int) $comment->file->module_instance_id === request()->route('module_instance_slug')->id()) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
235 22
                return $comment;
236
            }
237
            throw (new ModelNotFoundException)->setModel(Comment::class);
238 175
        });
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...
239 175
    }
240
241 175
    public function settings(): Form
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function settings()
Loading history...
242
    {
243
244 175
        return FormGenerator::make()->withGroup(
245 175
            Group::make('Page Design')->withField(
246 175
                Field::input('title')->inputType('text')->label('Module Title')->default('Page Title')
247 175
            )->withField(
248 175
                Field::textArea('description')->label('Description')->hint('This will appear at the top of the page')->rows(4)->default('Description')
249
            )
250 175
        )->withGroup(
251 175
            Group::make('New Documents')->withField(
252 175
                Field::input('document_title')->inputType('text')->label('Default document title')->hint('This will be the default title of a new file')->default('Document')
253 175
            )->withField(
254 175
                Field::switch('multiple_files')->label('Multiple Files')->hint('Should multiple files be able to be uploaded at the same time?')
255 175
                    ->textOn('Allow')->textOff('Do not allow')->default(true)
256 175
            )->withField(
257 175
                Field::checkList('allowed_extensions')->label('Allowed file types')->hint('Which file types can be uploaded?')
258 175
                    ->listBox(true)->values($this->app['config']->get($this->alias() . '.file_types'))
259 175
		                ->default(['doc', 'docx', 'odt', 'rtf', 'txt', 'csv', 'ppt', 'pptx', 'pdf', 'xls'])
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 20 spaces but found 18
Loading history...
260
            )
261 175
        )->withGroup(
262 175
            Group::make('Status Changes')->withField(
263 175
                Field::input('initial_status')->inputType('select')->label('Initial Status')->hint('What status should all new files have?')
264 175
                        ->default('Awaiting Approval')->values($this->app['config']->get($this->alias() . '.statuses'))
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 20 spaces but found 24
Loading history...
265 175
            )->withField(
266 175
                Field::checkList('statuses')->label('Available Statuses')->hint('A list of available statuses')
267 175
                    ->listBox(true)->values($this->app['config']->get($this->alias() . '.statuses'))
268
            )
269 175
        )->withGroup(
270 175
            Group::make('Tags')->withField(
271 175
                Field::make(TagList::class, 'new_tags')->label('New Tags')->hint('What tags should we assign when a new document is uploaded?')
272 175
            )->withField(
273 175
                Field::make(TagList::class, 'tags_to_merge')->label('Tags to merge')->hint('Any files with these tags will also be shown to the user')
274
            )
275 175
        )->getSchema();
276
    }
277
}