Completed
Push — master ( 09fb95...745d13 )
by ARCANEDEV
03:21
created

PermissionsRoutes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 87.1%

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 2
c 7
b 0
f 0
lcom 1
cbo 4
dl 0
loc 55
ccs 27
cts 31
cp 0.871
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B map() 0 43 2
1
<?php namespace Arcanesoft\Auth\Http\Routes\Foundation;
2
3
use Arcanedev\Support\Bases\RouteRegister;
4
use Arcanesoft\Auth\Models\Permission;
5
use Arcanesoft\Auth\Models\PermissionsGroup;
6
use Illuminate\Contracts\Routing\Registrar;
7
8
/**
9
 * Class     PermissionsRoutes
10
 *
11
 * @package  Arcanesoft\Auth\Http\Routes\Foundation
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class PermissionsRoutes extends RouteRegister
15
{
16
    /* ------------------------------------------------------------------------------------------------
17
     |  Main Functions
18
     | ------------------------------------------------------------------------------------------------
19
     */
20
    /**
21
     * Map routes.
22
     *
23
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
24
     */
25 24
    public function map(Registrar $router)
26
    {
27 24
        $this->group([
28 24
            'prefix'    => 'permissions',
29 18
            'as'        => 'permissions.',
30
        ], function () {
31 24
            $this->get('/', [
32 24
                'as'   => 'index',         // auth::foundation.permissions.index
33 18
                'uses' => 'PermissionsController@index',
34 18
            ]);
35
36 24
            $this->get('group/{perms_group_id}', [
37 24
                'as'   => 'group',         // auth::foundation.permissions.group
38 18
                'uses' => 'PermissionsController@group',
39 18
            ]);
40
41 24
            $this->group([
42
                'prefix' => '{permission_id}'
43
            ], function () {
44 24
                $this->get('show', [
45 24
                    'as'   => 'show',      // auth::foundation.permissions.show
46 18
                    'uses' => 'PermissionsController@show',
47 18
                ]);
48
49 24
                $this->delete('roles/{role_id}/detach', [
50 24
                    'as'   => 'roles.detach',  // auth::foundation.permissions.roles.detach
51 18
                    'uses' => 'PermissionsController@detachRole',
52 18
                ]);
53 24
            });
54 24
        });
55
56
        $this->bind('permission_id', function($hashedId) {
0 ignored issues
show
Bug introduced by
The method bind() does not seem to exist on object<Arcanesoft\Auth\H...tion\PermissionsRoutes>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
            return Permission::firstHashedOrFail($hashedId);
58 24
        });
59
60 24
        $this->bind('perms_group_id', function($hashedId) {
0 ignored issues
show
Bug introduced by
The method bind() does not seem to exist on object<Arcanesoft\Auth\H...tion\PermissionsRoutes>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
61
            if (head(hasher()->decode($hashedId)) === 0) {
62
                return null;
63
            }
64
65
            return PermissionsGroup::firstHashedOrFail($hashedId);
66 24
        });
67 24
    }
68
}
69