WizardController::step3()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace GitScrum\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use GitScrum\Models\ProductBacklog;
7
use Auth;
8
9
class WizardController extends Controller
10
{
11
    public function step1()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
12
    {
13
        $repositories = (object) app(Auth::user()->provider)->readRepositories();
14
        $currentRepositories = ProductBacklog::all();
15
16
        \Session::put('Repositories', $repositories);
17
18
        return view('wizard.step1')
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...
19
            ->with('repositories', $repositories)
20
            ->with('currentRepositories', $currentRepositories)
21
            ->with('columns', ['checkbox', 'repository', 'organization']);
22
    }
23
24
    public function step2(Request $request)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
25
    {
26
        $repositories = \Session::get('Repositories')->whereIn('provider_id', $request->repos);
27
        foreach ($repositories as $repository) {
28
            app(Auth::user()->provider)->readCollaborators($repository->organization_title, $repository->title, $repository->provider_id);
29
            $product_backlog = ProductBacklog::where('provider_id', $repository->provider_id)->first();
30
            if (!isset($product_backlog)) {
31
                $product_backlog = ProductBacklog::create(get_object_vars($repository));
32
            }
33
            app(Auth::user()->provider)->createBranches($repository->organization_title, $product_backlog->id, $repository->title, $repository->provider_id);
34
        }
35
36
        return view('wizard.step2')
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...
37
            ->with('repositories', $repositories)
38
            ->with('columns', ['repository', 'organization']);
39
    }
40
41
    public function step3()
42
    {
43
        $result = app(Auth::user()->provider)->readIssues();
0 ignored issues
show
Unused Code introduced by
$result 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...
44
45
        return redirect()->route('issues.index', ['slug' => 0]);
46
    }
47
}
48