GroupsRoutes::map()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 45
Code Lines 33

Duplication

Lines 15
Ratio 33.33 %

Importance

Changes 5
Bugs 2 Features 2
Metric Value
c 5
b 2
f 2
dl 15
loc 45
rs 8.8571
cc 1
eloc 33
nc 1
nop 1
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 groups routes class.
18
 */
19
class GroupsRoutes
20
{
21
    /**
22
     * Define the groups routes.
23
     *
24
     * @param \Illuminate\Contracts\Routing\Registrar $router
25
     */
26
    public function map(Registrar $router)
27
    {
28
        $router->group([
29
            'middleware' => ['app.hasSetting'],
30
            'setting' => 'app_name',
31
            'prefix' => 'groups',
32
            'as' => 'groups.',
33 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...
34
            $router->get('/', [
35
                'as' => 'index',
36
                'uses' => 'GroupsController@indexAction',
37
            ]);
38
            $router->get('new', [
39
                'as' => 'new',
40
                'uses' => 'GroupsController@newAction',
41
            ]);
42
43
            $router->post('create', [
44
                'as' => 'create',
45
                'uses' => 'GroupsController@createAction',
46
            ]);
47
        });
48
49
        // Project Sub-routes groups.group_show, groups.group_edit
50
        $router->group([
51
            'middleware' => ['app.hasSetting'],
52
            'setting' => 'app_name',
53
            'as' => 'groups.',
54
        ], function ($router) {
55
           $router->get('{owner_path}', [
56
                'as' => 'group_show',
57
                'uses' => 'GroupsController@showAction',
58
            ])->where('owner_path', '[a-zA-z.0-9_\-]+');
59
60
           $router->get('{owner_path}/edit', [
61
                'as' => 'group_edit',
62
                'uses' => 'GroupsController@editAction',
63
            ])->where('owner_path', '[a-zA-z.0-9_\-]+');
64
            $router->post('{owner_path}', [
65
                'as' => 'group_update',
66
                'uses' => 'GroupsController@updateAction',
67
            ])->where('owner_path', '[a-zA-z.0-9_\-]+');
68
69
        });
70
    }
71
}
72