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:33
created

PermissionCrudController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 49 4
A store() 0 4 1
A update() 0 4 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\PermissionCrudRequest as StoreRequest;
8
use Backpack\PermissionManager\app\Http\Requests\PermissionCrudRequest as UpdateRequest;
9
10
class PermissionCrudController 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($permission_model);
18
        $this->crud->setEntityNameStrings(trans('backpack::permissionmanager.permission_singular'), trans('backpack::permissionmanager.permission_plural'));
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 156 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').'/permission');
20
21
        $this->crud->addColumn([
22
            'name'  => 'name',
23
            'label' => trans('backpack::permissionmanager.name'),
24
            'type'  => 'text',
25
        ]);
26
        $this->crud->addColumn([ // n-n relationship (with pivot table)
27
            'label'     => trans('backpack::permissionmanager.roles_have_permission'),
28
            'type'      => 'select_multiple',
29
            'name'      => 'roles',
30
            'entity'    => 'roles',
31
            'attribute' => 'name',
32
            'model'     => $role_model,
33
            'pivot'     => true,
34
        ]);
35
36
        $this->crud->addField([
37
            'name'  => 'name',
38
            'label' => trans('backpack::permissionmanager.name'),
39
            'type'  => 'text',
40
        ]);
41
        $this->crud->addField([
42
            'label'     => trans('backpack::permissionmanager.roles'),
43
            'type'      => 'checklist',
44
            'name'      => 'roles',
45
            'entity'    => 'roles',
46
            'attribute' => 'name',
47
            'model'     => $role_model,
48
            'pivot'     => true,
49
        ]);
50
51
        if (!config('backpack.permissionmanager.allow_permission_create')) {
52
            $this->crud->denyAccess('create');
53
        }
54
        if (!config('backpack.permissionmanager.allow_permission_update')) {
55
            $this->crud->denyAccess('update');
56
        }
57
        if (!config('backpack.permissionmanager.allow_permission_delete')) {
58
            $this->crud->denyAccess('delete');
59
        }
60
    }
61
62
    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...
63
    {
64
        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...
65
    }
66
67
    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...
68
    {
69
        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...
70
    }
71
}
72