Completed
Pull Request — master (#24)
by Phecho
03:20
created

IssuesController   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 10 1
A new() 0 9 1
A create() 0 20 2
A show() 0 4 1
A edit() 0 4 1
A update() 0 4 1
A destroy() 0 4 1
1
<?php
2
3
namespace Gitamin\Http\Controllers\Projects;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Foundation\Bus\DispatchesJobs;
7
use Illuminate\Support\Facades\Redirect;
8
use Illuminate\Support\Facades\Auth;
9
use Illuminate\Support\Facades\View;
10
use Gitamin\Http\Controllers\Controller;
11
use GrahamCampbell\Binput\Facades\Binput;
12
use Gitamin\Commands\Issue\AddIssueCommand;
13
use Gitamin\Commands\Issue\RemoveIssueCommand;
14
use Gitamin\Commands\Issue\UpdateIssueCommand;
15
use Gitamin\Models\Project;
16
use Gitamin\Models\ProjectNamespace;
17
use Gitamin\Models\Group;
18
use Gitamin\Models\Tag;
19
use Gitamin\Models\Issue;
20
21
class IssuesController extends Controller
22
{
23
    
24
    protected $active_item = 'issues';
25
    /**
26
     * Display a listing of the resource.
27
     *
28
     * @return \Illuminate\Http\Response
29
     */
30
31
    public function index($namespace, $project_path)
32
    {
33
        $project = $this->getProject($namespace, $project_path);
34
        
35
        return View::make('projects.issues.index')
36
            ->withProject($project)
37
            ->withIssues($project->issues)
38
            ->withActiveItem($this->active_item)
39
            ->withPageTitle(sprintf('%s - %s', trans('dashboard.issues.issues'), $project->name));
40
    }
41
42
    public function new($namespace, $project_path)
43
    {
44
        $project = $this->getProject($namespace, $project_path);
45
46
        return View::make('projects.issues.new')
47
            ->withProject($project)
48
            ->withPageTitle(sprintf('%s - %s', trans('dashboard.issues.issues'), $project->name))
49
            ->withActiveItem($this->active_item);
50
    }
51
52
    /**
53
     * Show the form for creating a new resource.
54
     *
55
     * @return \Illuminate\Http\Response
56
     */
57
    public function create($namespace, $project_path)
58
    {
59
        $project = $this->getProject($namespace, $project_path);
60
        $issueData = Binput::get('issue');
61
62
         try {
63
            $issueData['author_id'] = Auth::user()->id;
64
            $issueData['project_id'] = $project->id;
65
            $issue = $this->dispatchFromArray(AddIssueCommand::class, $issueData);
0 ignored issues
show
Unused Code introduced by
$issue 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...
66
        } catch (ValidationException $e) {
0 ignored issues
show
Bug introduced by
The class Gitamin\Http\Controllers...cts\ValidationException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
67
            return Redirect::route('projects.issue_new')
68
                ->withInput(Binput::all())
69
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.issues.new.failure')))
70
                ->withErrors($e->getMessageBag());
71
        }
72
73
        return Redirect::route('projects.issue_index', ['namespace' => $namespace, 'project'=> $project_path])
74
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.issues.new.success')));
75
76
    }
77
78
    /**
79
     * Display the specified resource.
80
     *
81
     * @param  int  $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
82
     * @return \Illuminate\Http\Response
83
     */
84
    public function show($namespace, $project, Issue $issue)
0 ignored issues
show
Unused Code introduced by
The parameter $namespace is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $project is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $issue is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
    {
86
        //
87
    }
88
89
    /**
90
     * Show the form for editing the specified resource.
91
     *
92
     * @param  int  $id
93
     * @return \Illuminate\Http\Response
94
     */
95
    public function edit($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
96
    {
97
        //
98
    }
99
100
    /**
101
     * Update the specified resource in storage.
102
     *
103
     * @param  \Illuminate\Http\Request  $request
104
     * @param  int  $id
105
     * @return \Illuminate\Http\Response
106
     */
107
    public function update(Request $request, $id)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
108
    {
109
        //
110
    }
111
112
    /**
113
     * Remove the specified resource from storage.
114
     *
115
     * @param  int  $id
116
     * @return \Illuminate\Http\Response
117
     */
118
    public function destroy($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
119
    {
120
        //
121
    }
122
}
123