Completed
Push — master ( f021e4...96ea51 )
by Andrii
03:37
created

Initer::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 58
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 43
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 58
ccs 43
cts 43
cp 1
rs 9.639
c 1
b 1
f 0
cc 1
eloc 42
nc 1
nop 1
crap 1

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
3
/*
4
 * RBAC implementation for HiPanel
5
 *
6
 * @link      https://github.com/hiqdev/hipanel-rbac
7
 * @package   hipanel-rbac
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\rbac;
13
14
/**
15
 * Initer for AuthManager.
16
 *
17
 * @author Andrii Vasyliev <[email protected]>
18
 */
19
class Initer
20
{
21 3
    public static function init(AuthManager $auth)
22
    {
23 3
        $auth->setRole('client');
24 3
        $auth->setRole('support');
25 3
        $auth->setRole('admin');
26 3
        $auth->setRole('manager');
27 3
        $auth->setRole('reseller');
28 3
        $auth->setRole('owner');
29 3
        $auth->setRole('freezer');
30 3
        $auth->setRole('billManager');
31
32 3
        $auth->setPermission('deposit');
33 3
        $auth->setPermission('supporting');
34 3
        $auth->setPermission('manage');
35 3
        $auth->setPermission('administrate');
36 3
        $auth->setPermission('resell');
37 3
        $auth->setPermission('own');
38 3
        $auth->setPermission('root');
39 3
        $auth->setPermission('freeze');
40 3
        $auth->setPermission('unfreeze');
41 3
        $auth->setPermission('delete-bills');
42 3
        $auth->setPermission('edit-bills');
43
44 3
        $auth->setChild('client',           'deposit');
45
46 3
        $auth->setChild('support',          'supporting');
47
48 3
        $auth->setChild('admin',            'support');
49 3
        $auth->setChild('admin',            'administrate');
50
51 3
        $auth->setChild('manager',          'support');
52 3
        $auth->setChild('manager',          'manage');
53
54 3
        $auth->setChild('reseller',         'manager');
55 3
        $auth->setChild('reseller',         'resell');
56
57 3
        $auth->setChild('owner',            'reseller');
58 3
        $auth->setChild('owner',            'own');
59
60 3
        $auth->setChild('freezer',          'freeze');
61 3
        $auth->setChild('freezer',          'unfreeze');
62
63 3
        $auth->setChild('billManager',      'delete-bills');
64 3
        $auth->setChild('billManager',      'edit-bills');
65
66 3
        $auth->setAssignment('freezer',     'sol');
0 ignored issues
show
Documentation introduced by
'freezer' is of type string, but the function expects a object<hipanel\rbac\Role>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
67 3
        $auth->setAssignment('freezer',     'andre');
0 ignored issues
show
Documentation introduced by
'freezer' is of type string, but the function expects a object<hipanel\rbac\Role>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
68
69 3
        $auth->setAssignment('manager',     'sol');
0 ignored issues
show
Documentation introduced by
'manager' is of type string, but the function expects a object<hipanel\rbac\Role>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
70
71 3
        $auth->setAssignment('billManager', 'sol');
0 ignored issues
show
Documentation introduced by
'billManager' is of type string, but the function expects a object<hipanel\rbac\Role>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
72 3
        $auth->setAssignment('billManager', 'margo');
0 ignored issues
show
Documentation introduced by
'billManager' is of type string, but the function expects a object<hipanel\rbac\Role>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
73 3
        $auth->setAssignment('billManager', 'dsr');
0 ignored issues
show
Documentation introduced by
'billManager' is of type string, but the function expects a object<hipanel\rbac\Role>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
74 3
        $auth->setAssignment('billManager', 'olgadsr');
0 ignored issues
show
Documentation introduced by
'billManager' is of type string, but the function expects a object<hipanel\rbac\Role>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
75
76 3
77 3
        $auth->saveBasicAssignments();
78
    }
79 3
80
    public static function reinit(AuthManager $auth)
81 3
    {
82 3
        $auth->removeAll();
83 3
        static::init($auth);
84
    }
85
}
86