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

CourseController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 4 1
A store() 0 5 1
A show() 0 6 1
A update() 0 9 1
A destroy() 0 5 1
1
<?php
2
3
namespace NavJobs\Transmit\Templates;
4
5
use NavJobs\Transmit\Controller;
6
7
class CourseController 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($model);
0 ignored issues
show
Bug introduced by
The variable $model does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
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
    public function update($id, Request $request)
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