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.

ModuleServiceProvider::alias()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\AssignRoles;
4
5
use BristolSU\ControlDB\Contracts\Repositories\Position;
6
use BristolSU\Module\AssignRoles\CompletionConditions\RequiredPositionsFilled;
7
use BristolSU\Module\AssignRoles\Events\RoleCreated;
8
use BristolSU\Module\AssignRoles\Events\UserAssigned;
9
use BristolSU\Module\AssignRoles\Fields\PositionSettings;
10
use BristolSU\Support\Completion\Contracts\CompletionConditionManager;
11
use BristolSU\Support\Logic\Contracts\LogicRepository;
12
use BristolSU\Support\Logic\Logic;
13
use BristolSU\Support\Module\ModuleServiceProvider as ServiceProvider;
14
use FormSchema\Generator\Field;
15
use FormSchema\Generator\Group;
16
use FormSchema\Schema\Form;
17
use Illuminate\Support\Facades\Route;
18
19
class ModuleServiceProvider extends ServiceProvider
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ModuleServiceProvider
Loading history...
20
{
21
22
    protected $permissions = [
23
        'view-page' => [
24
            'name' => 'View Participant Page',
25
            'description' => 'View the main page of the module.',
26
            'admin' => false
27
        ],
28
        'admin.view-page' => [
29
            'name' => 'View Admin Page',
30
            'description' => 'View the administrator page of the module.',
31
            'admin' => true
32
        ],
33
        
34
        'assign' => [
35
            'name' => 'Assign a Role',
36
            'description' => 'Assign a role to a member of the group',
37
            'admin' => false
38
        ],
39
        'unassign' => [
40
            'name' => 'Unassign a Role',
41
            'description' => 'Unassign a user from a role',
42
            'admin' => false
43
        ],
44
        'see-members' => [
45
            'name' => 'See Member Lists',
46
            'description' => 'See a list of members that can be assigned roles',
47
            'admin' => false
48
        ],
49
        
50
        'role.index' => [
51
            'name' => 'See all roles',
52
            'description' => 'See a list of all existing roles for their group',
53
            'admin' => false
54
        ],
55
        'role.store' => [
56
            'name' => 'Create a role',
57
            'description' => 'Create a new role according to the settings',
58
            'admin' => false
59
        ],
60
        'role.delete' => [
61
            'name' => 'Delete a Role',
62
            'description' => 'Delete a role if no users are assigned to it',
63
            'admin' => false
64
        ],
65
        'role.update' => [
66
            'name' => 'Update a Role',
67
            'description' => 'Change the name and email of an existing role',
68
            'admin' => false
69
        ],
70
        
71
        
72
    ];
73
74
    protected $events = [
75
        RoleCreated::class => [
76
            'name' => 'Role Created',
77
            'description' => 'When a new role is created'
78
        ],
79
        UserAssigned::class => [
80
            'name' => 'User Assigned',
81
            'description' => 'When a user is assigned to a role'
82
        ],
83
    ];
84
85
    protected $commands = [
86
87
    ];
88
89 42
    public function alias(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function alias()
Loading history...
90
    {
91 42
        return 'assign-roles';
92
    }
93
94 42
    public function namespace()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function namespace()
Loading history...
95
    {
96 42
        return '\BristolSU\Module\AssignRoles\Http\Controllers';
97
    }
98
99 42
    public function baseDirectory()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function baseDirectory()
Loading history...
100
    {
101 42
        return __DIR__ . '/..';
102
    }
103
104 42
    public function boot()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function boot()
Loading history...
105
    {
106 42
        parent::boot();
107 42
        $this->registerGlobalScript('modules/assign-roles/js/components.js');
108
        
109 42
        app(CompletionConditionManager::class)->register('assign-roles', 'required_positions_are_filled', RequiredPositionsFilled::class);
110 42
    }
111
112 42
    public function register()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function register()
Loading history...
113
    {
114 42
        parent::register();
115 42
    }
116
117
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
118
     * @inheritDoc
119
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
120 42
    public function settings(): Form
121
    {
122 42
        return \FormSchema\Generator\Form::make()->withGroup(
123 42
            Group::make('Page Layout')->withField(
124 42
                Field::input('title')->inputType('text')->label('Title')->featured(false)->required(true)
125 42
                    ->default('Page Title')->hint('The title of the page')
126 42
                    ->help('This title will be shown at the top of the page, to help users understand what the module is for')
127 42
            )->withField(
128 42
                Field::input('subtitle')->inputType('text')->label('Subtitle')->featured(false)->required(true)
129 42
                    ->default('Page Subtitle')->hint('The subtitle for the page')
130 42
                    ->help('This subtitle will be shown under the title, and should include more information for users')
131 42
            )->withField(
132 42
                Field::input('no_settings')->inputType('text')->label('No Settings Text')->featured(false)->required(true)
133 42
                    ->default('No position settings found')->hint('Text to show if no position settings are found for the group')
134 42
                    ->help('If no position settings are found matching the group, an error page will be loaded. Use this text to explain what went wrong and how the user can fix it.')
135
            )
136 42
        )->withGroup(
137 42
            Group::make()->withField(
138 42
                Field::make(PositionSettings::class, 'position_settings')
139 42
                    ->label('Position Settings')->featured(true)->required(true)
140 42
                    ->default([])->hint('Define which positions can be assigned to whom')
141 42
                    ->help('Define the positions that may be used, positions which may only be held by one person and positions for which the assignee is not allowed any other positions')
142 42
                    ->logic($this->getLogic())
143 42
                    ->positions($this->getPositions())
144 42
            )->withField(
145 42
                Field::select('logic_group')->label('Logic Group to show')
146 42
                    ->featured(false)->required(false)->default(null)
147 42
                    ->hint('The logic group to show the roles from')
148 42
                    ->help('The logic group the roles should be in. If given, only roles in this logic group will be shown.')
149
                    ->values($this->getLogic()->map(function(Logic $logic) {
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...
150
                        return ['id' => $logic->id, 'name' => $logic->name];
151 42
                    }))
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...
152 42
                    ->selectOptions(['noneSelectedText' => '-- Show all roles --', 'hideNoneSelectedText' => false])
153
            )
154 42
        )->getSchema();
155
    }
156
157 42
    private function getLogic()
0 ignored issues
show
Coding Style introduced by
Private method name "ModuleServiceProvider::getLogic" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function getLogic()
Loading history...
158
    {
159
        try {
160 42
            return collect(app(LogicRepository::class)->all());
161 42
        } catch (\Exception $e) {
162 42
            return collect();
163
        }
164
    }
165
166 42
    private function getPositions()
0 ignored issues
show
Coding Style introduced by
Private method name "ModuleServiceProvider::getPositions" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function getPositions()
Loading history...
167
    {
168
        try {
169 42
            return collect(app(Position::class)->all());
170 42
        } catch (\Exception $e) {
171 42
            return collect();
172
        }
173
    }
174
}
175