Completed
Pull Request — master (#5)
by Zach
01:57
created

ResourceController::show()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace NavJobs\Transmit\Templates;
4
5
use NavJobs\Transmit\Controller;
6
7
class ResourceController extends Controller
8
{
9
    /**
10
     * Display a listing of the resource.
11
     *
12
     * @return \Illuminate\Http\Response
13
     */
14
    public function index()
15
    {
16
        return $this->respondWithPaginatedCollection();
17
    }
18
    /**
19
     * Store a newly created resource in storage.
20
     *
21
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Bug introduced by
There is no parameter named $request. 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...
22
     * @return \Illuminate\Http\Response
23
     */
24
    public function store()
25
    {
26
        $item = $this->model->create(request()->all());
0 ignored issues
show
Bug introduced by
The property model does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
27
        return $this->respondWithItem($item);
28
    }
29
    /**
30
     * Display the specified resource.
31
     *
32
     * @param  int  $id
33
     * @return \Illuminate\Http\Response
34
     */
35
    public function show($id)
36
    {
37
        return $this->respondWithItem($this->model, function ($model) use ($id) {
38
            return $model->findOrFail($id);
39
        });
40
    }
41
    /**
42
     * Update the specified resource in storage.
43
     *
44
     * @param  \Illuminate\Http\Request  $request
45
     * @param  int  $id
46
     * @return \Illuminate\Http\Response
47
     */
48 View Code Duplication
    public function update($id, Request $request)
0 ignored issues
show
Duplication introduced by
This method 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...
49
    {
50
        return $this->respondWithItem($this->model, function ($model) use ($id, $request) {
51
            $item = $model->findOrFail($id);
52
            $item->fill($request->all());
53
            $item->save();
54
            return $item;
55
        });
56
    }
57
    /**
58
     * Remove the specified resource from storage.
59
     *
60
     * @param  int  $id
61
     * @return \Illuminate\Http\Response
62
     */
63
    public function destroy($id)
64
    {
65
        $this->model->findOrFail($id)->delete();
66
        return $this->respondWithNoContent();
67
    }
68
}
69