Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#162)
by
unknown
01:38
created

RoleCrudController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 71
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 52 4
A store() 0 7 1
A update() 0 7 1
1
<?php
2
3
namespace Backpack\PermissionManager\app\Http\Controllers;
4
5
use Backpack\CRUD\app\Http\Controllers\CrudController;
6
// VALIDATION
7
use Backpack\PermissionManager\app\Http\Requests\RoleCrudRequest as StoreRequest;
8
use Backpack\PermissionManager\app\Http\Requests\RoleCrudRequest as UpdateRequest;
9
10
class RoleCrudController extends CrudController
11
{
12
    public function setup()
13
    {
14
        $role_model = config('permission.models.role');
15
        $permission_model = config('permission.models.permission');
16
17
        $this->crud->setModel($role_model);
18
        $this->crud->setEntityNameStrings(trans('backpack::permissionmanager.role'), trans('backpack::permissionmanager.roles'));
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 129 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
19
        $this->crud->setRoute(config('backpack.base.route_prefix').'/role');
20
21
        $this->crud->setColumns([
22
            [
23
                'name'  => 'name',
24
                'label' => trans('backpack::permissionmanager.name'),
25
                'type'  => 'text',
26
            ],
27
            [
28
                // n-n relationship (with pivot table)
29
                'label'     => ucfirst(trans('backpack::permissionmanager.permission_plural')),
30
                'type'      => 'select_multiple',
31
                'name'      => 'permissions', // the method that defines the relationship in your Model
32
                'entity'    => 'permissions', // the method that defines the relationship in your Model
33
                'attribute' => 'name', // foreign key attribute that is shown to user
34
                'model'     => $permission_model, // foreign key model
35
                'pivot'     => true, // on create&update, do you need to add/delete pivot table entries?
36
            ],
37
        ]);
38
39
        $this->crud->addField([
40
            'name'  => 'name',
41
            'label' => trans('backpack::permissionmanager.name'),
42
            'type'  => 'text',
43
        ]);
44
        $this->crud->addField([
45
            'label'     => ucfirst(trans('backpack::permissionmanager.permission_plural')),
46
            'type'      => 'checklist',
47
            'name'      => 'permissions',
48
            'entity'    => 'permissions',
49
            'attribute' => 'name',
50
            'model'     => $permission_model,
51
            'pivot'     => true,
52
        ]);
53
54
        if (config('backpack.permissionmanager.allow_role_create') == false) {
55
            $this->crud->denyAccess('create');
56
        }
57
        if (config('backpack.permissionmanager.allow_role_update') == false) {
58
            $this->crud->denyAccess('update');
59
        }
60
        if (config('backpack.permissionmanager.allow_role_delete') == false) {
61
            $this->crud->denyAccess('delete');
62
        }
63
    }
64
65
    public function store(StoreRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
    {
67
        //otherwise, changes won't have effect
68
        \Cache::forget('spatie.permission.cache');
69
70
        return parent::storeCrud();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (storeCrud() instead of store()). Are you sure this is correct? If so, you might want to change this to $this->storeCrud().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
71
    }
72
73
    public function update(UpdateRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
74
    {
75
        //otherwise, changes won't have effect
76
        \Cache::forget('spatie.permission.cache');
77
78
        return parent::updateCrud();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (updateCrud() instead of update()). Are you sure this is correct? If so, you might want to change this to $this->updateCrud().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
79
    }
80
}
81