Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( b393e2...607f68 )
by Cristian
02:55
created

ToneCrudController::crudStore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 9
Ratio 100 %
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 9
loc 9
rs 9.6666
1
<?php
2
3
namespace Backpack\Crud\app\Http\Controllers;
4
5
use Backpack\CRUD\Crud;
6
use Illuminate\Routing\Controller as BaseController;
7
8
/**
9
 * The controller that handles all the crud actions.
10
 */
11 View Code Duplication
class ToneCrudController extends BaseController
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...
12
{
13
    protected $crud;
14
    protected $data;
15
16
    public function __construct()
17
    {
18
        $this->crud = new Crud();
19
        $this->data = [];
20
    }
21
22
    /**
23
     * Display a listing of the resource.
24
     *
25
     * @return \Illuminate\Http\Response
26
     */
27
    public function index()
28
    {
29
        // dd($this->crud);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
30
        $this->crud->checkPermission('list');
0 ignored issues
show
Bug introduced by
The method checkPermission() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
32
        return view('crud::layouts.list', $this->data + ['crud' => $this->crud]);
33
    }
34
35
    /**
36
     * Show the form for creating a new resource.
37
     *
38
     * @return \Illuminate\Http\Response
39
     */
40
    public function create()
41
    {
42
        // dd($this->crud);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
        $this->crud->checkPermission('add');
0 ignored issues
show
Bug introduced by
The method checkPermission() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
45
        return view('crud::layouts.create', $this->data + ['crud' => $this->crud]);
46
    }
47
48
    /**
49
     * Store a newly created resource in storage.
50
     *
51
     * @param \Illuminate\Http\Request $request
52
     *
53
     * @return \Illuminate\Http\Response
54
     */
55
    public function crudStore(Request $request = null)
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...
56
    {
57
        // $this->crud->checkPermission('add');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
58
        // dd($request);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
59
        $entity = $this->crud->save(\Request::all());
0 ignored issues
show
Bug introduced by
The method save() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Unused Code introduced by
$entity 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...
60
61
        // return \Redirect::to($this->crud->getRoute()."/{$entity->id}/edit")->with('status', trans('crud::crud.form.create_success'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
62
        return \Redirect::to($this->crud->getRoute())->with('status', trans('crud::crud.form.create_success'));
63
    }
64
65
    /**
66
     * Display the specified resource.
67
     *
68
     * @param int $id
69
     *
70
     * @return \Illuminate\Http\Response
71
     */
72
    public function show($id)
73
    {
74
        $this->crud->checkPermission('view');
0 ignored issues
show
Bug introduced by
The method checkPermission() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
        $this->crud->item($id);
0 ignored issues
show
Bug introduced by
The method item() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76
77
        return view('crud::layouts.show', $this->data + ['crud' => $this->crud]);
78
    }
79
80
    /**
81
     * Show the form for editing the specified resource.
82
     *
83
     * @param int $id
84
     *
85
     * @return \Illuminate\Http\Response
86
     */
87
    public function edit($id)
88
    {
89
        $this->crud->checkPermission('edit');
0 ignored issues
show
Bug introduced by
The method checkPermission() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
90
        $this->crud->item($id);
0 ignored issues
show
Bug introduced by
The method item() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
91
92
        // dd($this->crud->item->toArray());
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
93
94
        return view('crud::layouts.edit', $this->data + ['crud' => $this->crud]);
95
    }
96
97
    /**
98
     * Update the specified resource in storage.
99
     *
100
     * @param \Illuminate\Http\Request $request
101
     * @param int                      $id
102
     *
103
     * @return \Illuminate\Http\Response
104
     */
105
    public function crudUpdate($id, Request $request = null)
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...
106
    {
107
        $this->crud->checkPermission('edit');
0 ignored issues
show
Bug introduced by
The method checkPermission() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
108
        $this->crud->item($id);
0 ignored issues
show
Bug introduced by
The method item() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
110
        $entity = $this->crud->update($id, \Request::all());
0 ignored issues
show
Unused Code introduced by
$entity 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...
111
112
        return \Redirect::to($this->crud->getRoute())->with('status', trans('crud::crud.form.save_success'));
113
    }
114
115
    /**
116
     * Remove the specified resource from storage.
117
     *
118
     * @param int $id
119
     *
120
     * @return \Illuminate\Http\Response
121
     */
122
    public function destroy($id)
123
    {
124
        $this->crud->checkPermission('delete');
0 ignored issues
show
Bug introduced by
The method checkPermission() does not seem to exist on object<Backpack\CRUD\Crud>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
125
126
        return $this->crud->delete($id);
127
    }
128
}
129