Completed
Push — master ( 6e4b3b...01af8d )
by ARCANEDEV
03:09
created

UsersRoutes::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 58
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 45
CRAP Score 1

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 58
ccs 45
cts 46
cp 0.9783
rs 9.6391
cc 1
eloc 35
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\User;
5
use Illuminate\Contracts\Routing\Registrar;
6
7
/**
8
 * Class     UsersRoutes
9
 *
10
 * @package  Arcanesoft\Auth\Http\Routes\Foundation
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class UsersRoutes 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
        parent::map($router);
27
28 24
        $this->group([
29 24
            'prefix'    => 'users',
30 18
            'as'        => 'users.',
31
        ], function () {
32 24
            $this->get('/', [
33 24
                'as'   => 'index',  // auth::foundation.users.index
34 18
                'uses' => 'UsersController@index',
35 18
            ]);
36
37 24
            $this->get('trash', [
38 24
                'as'   => 'trash',  // auth::foundation.users.trash
39 18
                'uses' => 'UsersController@trashList',
40 18
            ]);
41
42 24
            $this->get('create', [
43 24
                'as'   => 'create', // auth::foundation.users.create
44 18
                'uses' => 'UsersController@create',
45 18
            ]);
46
47 24
            $this->post('store', [
48 24
                'as'   => 'store',  // auth::foundation.users.store
49 18
                'uses' => 'UsersController@store',
50 18
            ]);
51
52 24
            $this->get('{user_id}/show', [
53 24
                'as'   => 'show',   // auth::foundation.users.show
54 18
                'uses' => 'UsersController@show',
55 18
            ]);
56
57 24
            $this->get('{user_id}/edit', [
58 24
                'as'   => 'edit',   // auth::foundation.users.edit
59 18
                'uses' => 'UsersController@edit',
60 18
            ]);
61
62 24
            $this->put('{user_id}/update', [
63 24
                'as'   => 'update', // auth::foundation.users.update
64 18
                'uses' => 'UsersController@update',
65 18
            ]);
66
67 24
            $this->put('{user_id}/restore', [
68 24
                'as'   => 'restore', // auth::foundation.users.restore
69 18
                'uses' => 'UsersController@restore',
70 18
            ]);
71
72 24
            $this->delete('{user_id}/delete', [
73 24
                'as'   => 'delete', // auth::foundation.users.delete
74 18
                'uses' => 'UsersController@delete',
75 18
            ]);
76 24
        });
77
78 24
        $router->bind('user_id', function($hashedId) {
79
            return User::firstHashedOrFail($hashedId);
80 24
        });
81 24
    }
82
}
83