Completed
Push — master ( 009dae...e9add0 )
by Phecho
03:14
created

DefaultRoutes::map()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 90
Code Lines 59

Duplication

Lines 17
Ratio 18.89 %

Importance

Changes 10
Bugs 4 Features 2
Metric Value
c 10
b 4
f 2
dl 17
loc 90
rs 8.5455
cc 1
eloc 59
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
            'as'         => 'dashboard.'
33
        ], function ($router) {
34
            $router->get('/', [
35
                'as'   => 'index',
36
                'uses' => 'DashboardController@indexAction',
37
            ]);
38
        });
39
        //Install Area
40
        $router->group(['middleware' => ['app.isInstalled', 'localize']], function ($router) {
41
            $router->controller('install', 'InstallController');
42
        });
43
44
        //Signup Area
45
        $router->group([
46
            'middleware' => ['app.hasSetting', 'guest'],
47
            'setting'    => 'app_name',
48
            'as'         => 'signup.',
49
        ], function ($router) {
50
            $router->get('signup', [
51
                'as'         => 'signup',
52
                'uses'       => 'SignupController@getSignup',
53
            ]);
54
            $router->post('signup', [
55
                'uses' => 'SignupController@postSignup',
56
            ]);
57
58
            $router->get('signup/invite/{code}', [
59
                'as' => 'invite',
60
                'uses' => 'SignupController@getSignup',
61
            ]);
62
            $router->post('signup/invite/{code}', [
63
                'uses' => 'SignupController@postSignup',
64
            ]);
65
        });
66
67
        //Explore Area
68
        $router->group([
69
            'middleware' => ['app.hasSetting'],
70
            'setting'    => 'app_name',
71
            'prefix'     => 'explore',
72
            'as'         => 'explore.',
73 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...
74
            $router->get('/', [
75
                'as'   => 'index',
76
                'uses' => 'ExploreController@indexAction',
77
            ]);
78
            $router->get('groups', [
79
                'as'    => 'groups',
80
                'uses'  => 'ExploreController@groupsAction',
81
            ]);
82
83
            $router->get('issue/{issue}', [
84
                'as'    => 'issue',
85
                'uses'  => 'ExploreController@showIssue',
86
            ]);
87
        });
88
89
        // Feed Area
90
        $router->group([
91
            'middleware' => 'app.hasSetting',
92
            'setting'    => 'app_name',
93
        ], function ($router) {
94
            $router->get('/atom/{namespace?}', [
95
                'as'   => 'feed.atom',
96
                'uses' => 'FeedController@atomAction',
97
            ]);
98
            $router->get('/rss/{namespace?}', [
99
                'as'   => 'feed.rss',
100
                'uses' => 'FeedController@rssAction',
101
            ]);
102
        });
103
104
        // Profile Area
105
        $router->group([
106
            'middleware' => ['app.hasSetting'],
107
            'setting'    => 'app_name',
108
            'as'         => 'profile.',
109
        ], function ($router) {
110
            $router->get('profile', [
111
                'as'   => 'index',
112
                'uses' => 'ProfilesController@indexAction',
113
            ]);
114
        });
115
    }
116
}
117