GroupsController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 18 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 2
c 3
b 1
f 2
lcom 1
cbo 1
dl 9
loc 50
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 9 9 1
A __construct() 0 22 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Controllers\Dashboard;
13
14
use Gitamin\Http\Controllers\Controller;
15
use Gitamin\Models\Group;
16
use Gitamin\Models\Project;
17
use Illuminate\Support\Facades\View;
18
19
class GroupsController extends Controller
20
{
21
    /**
22
     * Array of sub-menu items.
23
     *
24
     * @var array
25
     */
26
    protected $subMenu = [];
27
28
    /**
29
     * Creates a new project controller instance.
30
     */
31
    public function __construct()
32
    {
33
        $this->subMenu = [
34
            'yours' => [
35
                'title' => trans_choice('gitamin.groups.yours', 2),
36
                'url' => route('dashboard.groups.index'),
37
                'icon' => 'fa fa-folder',
38
                'active' => false,
39
            ],
40
            'explore' => [
41
                'title' => trans('gitamin.groups.explore'),
42
                'url' => route('explore.groups'),
43
                'icon' => 'fa fa-eye',
44
                'active' => false,
45
            ],
46
        ];
47
48
        View::share([
49
            'sub_menu' => $this->subMenu,
50
            'sub_title' => trans_choice('dashboard.groups.groups', 2),
51
        ]);
52
    }
53
54
    /**
55
     * Shows the project group view.
56
     *
57
     * @return \Illuminate\View\View
58
     */
59 View Code Duplication
    public function indexAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
60
    {
61
        $this->subMenu['yours']['active'] = true;
62
63
        return View::make('dashboard.groups.index')
64
            ->withPageTitle(trans_choice('gitamin.groups.groups', 2).' - '.trans('dashboard.dashboard'))
65
            ->withGroups(Group::IsGroup()->Mine()->get())
0 ignored issues
show
Bug introduced by
The method IsGroup() does not exist on Gitamin\Models\Group. Did you maybe mean scopeIsGroup()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
66
            ->withSubMenu($this->subMenu);
67
    }
68
}
69