DefaultRoutes::map()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 93
Code Lines 61

Duplication

Lines 27
Ratio 29.03 %

Importance

Changes 12
Bugs 4 Features 4
Metric Value
c 12
b 4
f 4
dl 27
loc 93
rs 8.4643
cc 1
eloc 61
nc 1
nop 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
2
3
/*
4
 * This file is part of Gitamin.
5
 *
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Http\Routes;
13
14
use Illuminate\Contracts\Routing\Registrar;
15
16
/**
17
 * This is the default routes class.
18
 */
19
class DefaultRoutes
20
{
21
    /**
22
     * Define the install routes.
23
     *
24
     * @param \Illuminate\Contracts\Routing\Registrar $router
25
     */
26
    public function map(Registrar $router)
27
    {
28
        //Default - Dashboard
29
        $router->group([
30
            'middleware' => ['app.hasSetting', 'auth'],
31
            'setting' => 'app_name',
32
        ], function ($router) {
33
            $router->get('/', [
34
                'as' => 'home',
35
                'uses' => 'DashboardController@indexAction',
36
            ]);
37
        });
38
        //Install Area
39
        $router->group(['middleware' => ['app.isInstalled', 'localize']], function ($router) {
40
            $router->controller('install', 'InstallController');
41
        });
42
43
        //Signup Area
44
        $router->group([
45
            'middleware' => ['app.hasSetting', 'guest'],
46
            'setting' => 'app_name',
47
            'as' => 'signup.',
48
        ], function ($router) {
49
            $router->get('signup', [
50
                'as' => 'signup',
51
                'uses' => 'SignupController@getSignup',
52
            ]);
53
            $router->post('signup', [
54
                'uses' => 'SignupController@postSignup',
55
            ]);
56
57
            $router->get('signup/invite/{code}', [
58
                'as' => 'invite',
59
                'uses' => 'SignupController@getSignup',
60
            ]);
61
            $router->post('signup/invite/{code}', [
62
                'uses' => 'SignupController@postSignup',
63
            ]);
64
        });
65
66
        //Explore Area
67
        $router->group([
68
            'middleware' => ['app.hasSetting'],
69
            'setting' => 'app_name',
70
            'prefix' => 'explore',
71
            'as' => 'explore.',
72 View Code Duplication
        ], function ($router) {
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...
73
            $router->get('/', [
74
                'as' => 'index',
75
                'uses' => 'ExploreController@indexAction',
76
            ]);
77
            $router->get('groups', [
78
                'as' => 'groups',
79
                'uses' => 'ExploreController@groupsAction',
80
            ]);
81
82
            $router->get('issue/{issue}', [
83
                'as' => 'issue',
84
                'uses' => 'ExploreController@showIssue',
85
            ]);
86
        });
87
88
        // Feed Area
89
        $router->group([
90
            'middleware' => 'app.hasSetting',
91
            'setting' => 'app_name',
92
        ], function ($router) {
93
            $router->get('/atom/{namespace?}', [
94
                'as' => 'feed.atom',
95
                'uses' => 'FeedController@atomAction',
96
            ]);
97
            $router->get('/rss/{namespace?}', [
98
                'as' => 'feed.rss',
99
                'uses' => 'FeedController@rssAction',
100
            ]);
101
        });
102
103
        // Profile Area
104
        $router->group([
105
            'middleware' => ['app.hasSetting'],
106
            'setting' => 'app_name',
107
            'as' => 'profile.',
108 View Code Duplication
        ], function ($router) {
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...
109
            $router->get('profile', [
110
                'as' => 'index',
111
                'uses' => 'ProfilesController@indexAction',
112
            ]);
113
            $router->post('profile', [
114
                'as' => 'update',
115
                'uses' => 'ProfilesController@updateAction',
116
            ]);
117
        });
118
    }
119
}
120