UserIssueController::destroy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
/**
3
 * GitScrum v0.1.
4
 *
5
 * @author  Renato Marinho <[email protected]>
6
 * @license http://opensource.org/licenses/GPL-3.0 GPLv3
7
 */
8
9
namespace GitScrum\Http\Controllers;
10
11
use Illuminate\Http\Request;
12
use GitScrum\Models\Issue;
13
use GitScrum\Models\User;
14
15
class UserIssueController extends Controller
16
{
17
    /**
18
     * Display a listing of the resource.
19
     *
20
     * @return \Illuminate\Http\Response
21
     */
22
    public function index($username, $slug_type = null)
23
    {
24
        $issues = Issue::join('sprints', 'issues.sprint_id', '=', 'sprints.id')
25
            ->join('issues_has_users', 'issues_has_users.issue_id', '=', 'issues.id')
26
            ->join('users', 'users.id', '=', 'issues_has_users.user_id')
27
            ->join('issue_types', 'issues.issue_type_id', '=', 'issue_types.id')
28
            ->where('users.username', $username);
29
30
        if (!is_null($slug_type)) {
31
            $issues = $issues->where('issue_types.slug', $slug_type);
32
        }
33
34
        $issues = $issues->orderby('issues.position', 'ASC')
35
            ->select('issues.*')->paginate(env('APP_PAGINATE'));
36
37
        $user = User::where('username', $username)
38
            ->where('provider', Auth::user()->provider)
39
            ->first();
40
41
        return view('user_issues.index')
0 ignored issues
show
Bug introduced by
The method with does only exist in Illuminate\View\View, but not in Illuminate\Contracts\View\Factory.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
42
            ->with('issues', $issues)
43
            ->with('user', $user);
44
    }
45
46
    /**
47
     * Show the form for creating a new resource.
48
     *
49
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
50
     */
51
    public function create()
52
    {
53
    }
54
55
    /**
56
     * Store a newly created resource in storage.
57
     *
58
     * @param \Illuminate\Http\Request $request
59
     *
60
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
61
     */
62
    public function store(Request $request)
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...
63
    {
64
    }
65
66
    /**
67
     * Display the specified resource.
68
     *
69
     * @param int $id
70
     *
71
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
72
     */
73
    public function show($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...
74
    {
75
    }
76
77
    /**
78
     * Show the form for editing the specified resource.
79
     *
80
     * @param int $id
81
     *
82
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
83
     */
84
    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...
85
    {
86
    }
87
88
    /**
89
     * Update the specified resource in storage.
90
     *
91
     * @param \Illuminate\Http\Request $request
92
     * @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...
93
     *
94
     * @return \Illuminate\Http\Response
95
     */
96
    public function update(Request $request, $slug)
97
    {
98
        $members = $request->input('members');
99
100
        $issue = Issue::slug($slug)
101
            ->firstOrFail();
102
103
        $issue->users()->sync($members);
104
105
        if (!$request->ajax()) {
106
            return redirect()->back()->with('success', trans('Updated successfully'));
107
        }
108
    }
109
110
    /**
111
     * Remove the specified resource from storage.
112
     *
113
     * @param int $id
114
     *
115
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
116
     */
117
    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...
118
    {
119
    }
120
}
121