ProjectsRoutes::map()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 106
Code Lines 77

Duplication

Lines 16
Ratio 15.09 %

Importance

Changes 12
Bugs 4 Features 5
Metric Value
c 12
b 4
f 5
dl 16
loc 106
rs 8.2857
cc 1
eloc 77
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 projects routes class.
18
 */
19
class ProjectsRoutes
20
{
21
    /**
22
     * Define the projects routes.
23
     *
24
     * @param \Illuminate\Contracts\Routing\Registrar $router
25
     */
26
    public function map(Registrar $router)
27
    {
28
        // Project Area
29
        $router->group([
30
            'middleware' => ['app.hasSetting'],
31
            'setting' => 'app_name',
32
            'prefix' => 'projects',
33
            'as' => 'projects.',
34 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...
35
            $router->get('/', [
36
                'as' => 'index',
37
                'uses' => 'ProjectsController@indexAction',
38
            ]);
39
            $router->get('new', [
40
                'as' => 'new',
41
                'uses' => 'ProjectsController@newAction',
42
            ]);
43
            $router->post('create', [
44
                'as' => 'create',
45
                'uses' => 'ProjectsController@createAction',
46
            ]);
47
        });
48
49
        // Project Sub-routes
50
        $router->group([
51
            'middleware' => ['app.hasSetting'],
52
            'setting' => 'app_name',
53
            'as' => 'projects.',
54
        ], function ($router) {
55
           $router->get('{owner_path}/{project_path}', [
56
                'as' => 'project_show',
57
                'uses' => 'ProjectsController@showAction',
58
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
59
60
           $router->get('{owner_path}/{project_path}/edit', [
61
                'as' => 'project_edit',
62
                'uses' => 'ProjectsController@editAction',
63
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
64
            $router->post('{owner_path}/{project_path}', [
65
                'as' => 'project_update',
66
                'uses' => 'ProjectsController@updateAction',
67
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
68
69
            //Issues
70
            $router->get('{owner_path}/{project_path}/issues', [
71
                'as' => 'issue_index',
72
                'uses' => 'Projects\\IssuesController@indexAction',
73
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
74
            //new
75
            $router->get('{owner_path}/{project_path}/issues/new', [
76
                'as' => 'issue_new',
77
                'uses' => 'Projects\\IssuesController@newAction',
78
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
79
            //create
80
            $router->post('{owner_path}/{project_path}/issues', [
81
                'as' => 'issue_create',
82
                'uses' => 'Projects\\IssuesController@createAction',
83
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
84
            //show
85
            $router->get('{owner_path}/{project_path}/issues/{issue}', [
86
                'as' => 'issue_show',
87
                'uses' => 'Projects\\IssuesController@showAction',
88
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
89
             //edit
90
            $router->get('{owner_path}/{project_path}/issues/{issue}/edit', [
91
                'as' => 'issue_edit',
92
                'uses' => 'Projects\\IssuesController@editAction',
93
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
94
            //update
95
            $router->post('{owner_path}/{project_path}/issues/{issue}', [
96
                'as' => 'issue_update',
97
                'uses' => 'Projects\\IssuesController@updateAction',
98
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
99
100
            //Pull Requests
101
            $router->get('{owner_path}/{project_path}/pulls', [
102
                'as' => 'pull_index',
103
                'uses' => 'Projects\\PullRequestsController@indexAction',
104
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
105
106
            //Wiki
107
            $router->get('{owner_path}/{project_path}/wiki', [
108
                'as' => 'wiki_index',
109
                'uses' => 'Projects\\WikiController@indexAction',
110
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
111
112
            //Pulse
113
            $router->get('{owner_path}/{project_path}/pulse', [
114
                'as' => 'pulse_index',
115
                'uses' => 'Projects\\PulseController@indexAction',
116
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
117
118
            //Graphs
119
            $router->get('{owner_path}/{project_path}/graphs', [
120
                'as' => 'graph_index',
121
                'uses' => 'Projects\\GraphsController@indexAction',
122
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
123
124
            //Comments
125
            //create
126
            $router->post('{owner_path}/{project_path}/comments', [
127
                'as' => 'comment_create',
128
                'uses' => 'Projects\\CommentsController@createAction',
129
            ])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+');
130
        });
131
    }
132
}
133