Completed
Pull Request — master (#107)
by Tim
23:41 queued 15:32
created

TypesController   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 6
Bugs 2 Features 4
Metric Value
wmc 8
c 6
b 2
f 4
lcom 0
cbo 4
dl 0
loc 96
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A index() 0 5 1
A create() 0 4 1
A store() 0 9 1
A show() 0 4 1
A edit() 0 4 1
A update() 0 4 1
A destroy() 0 7 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Tasks;
6
use Illuminate\Http\Request;
7
8
use App\Http\Requests;
9
use App\Http\Controllers\Controller;
10
11
/**
12
 * Class TypesController
13
 * @package App\Http\Controllers
14
 */
15
class TypesController extends Controller
16
{
17
    /**
18
     * TypesController constructor.
19
     */ 
20
    public function __construct()
21
    {
22
        $this->middleware('auth');
23
        $this->middleware('lang');
24
    }
25
26
    /**
27
     * Display a listing of the resource.
28
     *
29
     * @return \Illuminate\Http\Response
30
     */
31
    public function index()
32
    {
33
        $data['tasks'] = Tasks::all();
0 ignored issues
show
Coding Style Comprehensibility introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
34
        return view('tasks.manage_types', $data);
35
    }
36
37
    /**
38
     * Show the form for creating a new resource.
39
     *
40
     * @return \Illuminate\Http\Response
41
     */
42
    public function create()
43
    {
44
        //
45
    }
46
47
    /**
48
     * Store a newly created resource in storage.
49
     *
50
     * @param Requests\taskValidator|Request $request
51
     * @return \Illuminate\Http\Response
52
     */
53
    public function store(Requests\taskValidator $request)
54
    {
55
        // Input: name
56
        // Input: Priority.
57
        Tasks::create($request->except('_token'));
58
59
        session()->flash('message', 'FlashSession.typesInsert');
60
        return redirect()->back();
61
    }
62
63
    /**
64
     * Display the specified resource.
65
     *
66
     * @param  int  $id
67
     * @return \Illuminate\Http\Response
68
     */
69
    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...
70
    {
71
        //
72
    }
73
74
    /**
75
     * Show the form for editing the specified resource.
76
     *
77
     * @param  int  $id
78
     * @return \Illuminate\Http\Response
79
     */
80
    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...
81
    {
82
        //
83
    }
84
85
    /**
86
     * Update the specified resource in storage.
87
     *
88
     * @param  \Illuminate\Http\Request  $request
89
     * @param  int  $id
90
     * @return \Illuminate\Http\Response
91
     */
92
    public function update(Request $request, $id)
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...
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...
93
    {
94
        //
95
    }
96
97
    /**
98
     * Remove the specified resource from storage.
99
     *
100
     * @param  int  $id
101
     * @return \Illuminate\Http\Response
102
     */
103
    public function destroy(Request $request, $id)
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...
104
    {
105
        Tasks::destroy($id);
106
        session()->flash('message', trans('FlashSession.typesDelete'));
107
108
        return redirect()->back();
109
    }
110
}
111