Completed
Push — master ( e40024...27a431 )
by ARCANEDEV
03:09
created

RolesRoutes::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 51
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 40
CRAP Score 1

Importance

Changes 6
Bugs 0 Features 0
Metric Value
c 6
b 0
f 0
dl 0
loc 51
ccs 40
cts 41
cp 0.9756
rs 9.4109
cc 1
eloc 31
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 namespace Arcanesoft\Auth\Http\Routes\Foundation;
2
3
use Arcanedev\Support\Bases\RouteRegister;
4
use Arcanesoft\Auth\Models\Role;
5
use Illuminate\Contracts\Routing\Registrar;
6
7
/**
8
 * Class     RolesRoutes
9
 *
10
 * @package  Arcanesoft\Auth\Http\Routes\Foundation
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class RolesRoutes extends RouteRegister
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Main Functions
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Map routes.
21
     *
22
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
23
     */
24 24
    public function map(Registrar $router)
25
    {
26 24
        $this->group([
27 24
            'prefix'    => 'roles',
28 18
            'as'        => 'roles.',
29
        ], function () {
30 24
            $this->get('/', [
31 24
                'as'   => 'index',    // auth::foundation.roles.index
32 18
                'uses' => 'RolesController@index',
33 18
            ]);
34
35 24
            $this->get('create', [
36 24
                'as'   => 'create',   // auth::foundation.roles.create
37 18
                'uses' => 'RolesController@create',
38 18
            ]);
39
40 24
            $this->post('store', [
41 24
                'as'   => 'store',    // auth::foundation.roles.store
42 18
                'uses' => 'RolesController@store',
43 18
            ]);
44
45 24
            $this->get('{role_id}/show', [
46 24
                'as'   => 'show',     // auth::foundation.roles.show
47 18
                'uses' => 'RolesController@show',
48 18
            ]);
49
50 24
            $this->get('{role_id}/edit', [
51 24
                'as'   => 'edit',     // auth::foundation.roles.edit
52 18
                'uses' => 'RolesController@edit',
53 18
            ]);
54
55 24
            $this->put('{role_id}/update', [
56 24
                'as'   => 'update',   // auth::foundation.roles.update
57 18
                'uses' => 'RolesController@update',
58 18
            ]);
59
60 24
            $this->put('{role_id}/activate', [
61 24
                'as'   => 'activate', // auth::foundation.roles.activate
62 18
                'uses' => 'RolesController@activate',
63 18
            ]);
64
65 24
            $this->delete('{role_id}/delete', [
66 24
                'as'   => 'delete',   // auth::foundation.roles.delete
67 18
                'uses' => 'RolesController@delete',
68 18
            ]);
69 24
        });
70
71 24
        $router->bind('role_id', function($hashedId) {
72
            return Role::firstHashedOrFail($hashedId);
73 24
        });
74 24
    }
75
}
76