Completed
Push — master ( 3d2689...4e480b )
by Abdelrahman
13:42 queued 11:55
created

helpers.php ➔ get_area_roles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
if (! function_exists('get_area_roles')) {
6
    /**
7
     * Get area roles.
8
     *
9
     * @param mixed $currentUser
10
     *
11
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be array? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
12
     */
13
    function get_area_roles($currentUser)
0 ignored issues
show
Coding Style introduced by
As per coding-style, this function should be in camelCase.

CamelCase (...) is the practice of writing compound words or phrases such that
each word or abbreviation begins with a capital letter.

Learn more about camelCase.

Loading history...
14
    {
15
        $roles = $currentUser->can('superadmin') ? app('cortex.auth.role')->all() : $currentUser->roles;
16
        $roles = $roles->pluck('title', 'id')->toArray();
17
18
        asort($roles);
19
20
        return $roles;
21
    }
22
}
23
24
if (! function_exists('get_area_abilities')) {
25
    /**
26
     * Get area abilites.
27
     *
28
     * @param mixed $currentUser
29
     *
30
     * @return string
31
     */
32
    function get_area_abilities($currentUser)
0 ignored issues
show
Coding Style introduced by
As per coding-style, this function should be in camelCase.

CamelCase (...) is the practice of writing compound words or phrases such that
each word or abbreviation begins with a capital letter.

Learn more about camelCase.

Loading history...
33
    {
34
        $abilities = $currentUser->can('superadmin') ? app('cortex.auth.ability')->all() : $currentUser->getAbilities();
35
        $abilities = $abilities->groupBy('entity_type')->map->pluck('title', 'id')->sortKeys()->toArray();
36
37
        return $abilities;
38
    }
39
}
40