DashboardController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 2
c 2
b 0
f 2
lcom 1
cbo 1
dl 0
loc 77
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 46 1
A indexAction() 0 19 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\Controllers\Admin;
13
14
use Gitamin\Models\Project;
15
use Illuminate\Routing\Controller;
16
use Illuminate\Support\Facades\Session;
17
use Illuminate\Support\Facades\View;
18
19
class DashboardController extends Controller
20
{
21
    /**
22
     * Creates a new settings controller instance.
23
     */
24
    public function __construct()
25
    {
26
        $this->subMenu = [
0 ignored issues
show
Bug introduced by
The property subMenu does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
27
            'overview' => [
28
                'title' => 'Overview',
29
                'url' => route('admin.index'),
30
                'icon' => 'fa fa-wrench',
31
                'active' => false,
32
            ],
33
            'general' => [
34
                'title' => trans('admin.settings.general.general'),
35
                'url' => route('admin.settings.general'),
36
                'icon' => 'fa fa-gear',
37
                'active' => false,
38
            ],
39
            'theme' => [
40
                'title' => trans('admin.settings.theme.theme'),
41
                'url' => route('admin.settings.theme'),
42
                'icon' => 'fa fa-list-alt',
43
                'active' => false,
44
            ],
45
            'stylesheet' => [
46
                'title' => trans('admin.settings.stylesheet.stylesheet'),
47
                'url' => route('admin.settings.stylesheet'),
48
                'icon' => 'fa fa-magic',
49
                'active' => false,
50
            ],
51
            'localization' => [
52
                'title' => trans('admin.settings.localization.localization'),
53
                'url' => route('admin.settings.localization'),
54
                'icon' => 'fa fa-language',
55
                'active' => false,
56
            ],
57
            'timezone' => [
58
                'title' => trans('admin.settings.timezone.timezone'),
59
                'url' => route('admin.settings.timezone'),
60
                'icon' => 'fa fa-calendar',
61
                'active' => false,
62
            ],
63
        ];
64
65
        View::share([
66
            'sub_title' => trans('admin.admin'),
67
            'sub_menu' => $this->subMenu,
68
        ]);
69
    }
70
71
    /**
72
     * Display a listing of the resource.
73
     *
74
     * @return \Illuminate\Http\Response
75
     */
76
    public function indexAction()
77
    {
78
        $this->subMenu['overview']['active'] = true;
79
80
        Session::flash('redirect_to', $this->subMenu['general']['url']);
81
82
        $projects = Project::orderBy('created_at')->get();
0 ignored issues
show
Unused Code introduced by
$projects is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
83
84
        $projects = Project::get();
85
        $issues = [];
86
        $subscribers = [];
87
88
        return View::make('admin.index')
89
            ->withPageTitle(trans('admin.admin'))
90
            ->withProjects($projects)
91
            ->withIssues($issues)
92
            ->withSubscribers($subscribers)
93
            ->withSubMenu($this->subMenu);
94
    }
95
}
96