Completed
Push — master ( 3a6e78...84eb52 )
by Mads
02:50
created

helpers.php ➔ has_role()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2 View Code Duplication
if (!function_exists('acl')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3
    /**
4
     * @return \Napp\Core\Acl\AclService
5
     */
6
    function acl()
7
    {
8 8
        $arguments = func_get_args();
9 8
        if (empty($arguments)) {
10 2
            return app(\Napp\Core\Acl\AclService::class);
11
        }
12
13 6
        return app(\Napp\Core\Acl\AclService::class)->may($arguments[0]);
14
    }
15
}
16
17 View Code Duplication
if (!function_exists('may')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    /**
19
     * @return \Napp\Core\Acl\AclService
20
     */
21
    function may()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
22
    {
23 4
        $arguments = func_get_args();
24 4
        if (empty($arguments)) {
25 2
            return app(\Napp\Core\Acl\AclService::class);
26
        }
27
28 2
        return app(\Napp\Core\Acl\AclService::class)->may($arguments[0]);
29
    }
30
}
31
32
if (!function_exists('maynot')) {
33
    /**
34
     * @param string|array $permission
35
     * @return \Napp\Core\Acl\AclService
36
     */
37
    function maynot($permission)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
38
    {
39 2
        return app(\Napp\Core\Acl\AclService::class)->maynot($permission);
40
    }
41
}
42
43
if (!function_exists('mayall')) {
44
    /**
45
     * @param array $permissions
46
     * @return \Napp\Core\Acl\AclService
47
     */
48
    function mayall(array $permissions)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
49
    {
50 2
        return app(\Napp\Core\Acl\AclService::class)->mayall($permissions);
51
    }
52
}
53
54
if (!function_exists('has_role')) {
55
    /**
56
     * @param \Napp\Core\Acl\Contract\Role|null $user
57
     * @param array|string $roles
58
     * @return \Napp\Core\Acl\AclService
59
     */
60
    function has_role($user, $roles)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
61
    {
62 2
        return app(\Napp\Core\Acl\AclService::class)->userHasRole($user, $roles);
63
    }
64
}