GraphsController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 95 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A indexAction() 10 10 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\Projects;
13
14
use Gitamin\Http\Controllers\Controller;
15
use Gitamin\Models\Project;
16
use Illuminate\Support\Facades\View;
17
18 View Code Duplication
class GraphsController extends Controller
0 ignored issues
show
Duplication introduced by
This class 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...
19
{
20
    protected $active_item = 'graphs';
21
22
    /**
23
     * Display a listing of the resource.
24
     *
25
     * @return \Illuminate\Http\Response
26
     */
27
    public function indexAction($namespace, $project_path)
28
    {
29
        $project = Project::findByPath($namespace, $project_path);
30
31
        return View::make('projects.graphs.index')
32
            ->withProject($project)
33
            ->withWikis([])
34
            ->withActiveItem($this->active_item)
35
            ->withPageTitle(sprintf('%s - %s', trans('dashboard.issues.issues'), $project->name));
0 ignored issues
show
Documentation introduced by
The property name does not exist on object<Gitamin\Models\User>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
36
    }
37
}
38