Completed
Push — develop ( e1ba06...9ac8df )
by
unknown
14:59 queued 06:41
created

DeviceController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Api\Controllers;
4
5
use App\User;
6
use App\Device;
7
use App\Port;
8
use Illuminate\Http\Request;
9
10
class DeviceController extends Controller
11
{
12
    public function __construct() {
13
14
    }
15
16
    /**
17
     * Display a listing of all authorized devices
18
     *
19
     * @return \Illuminate\Http\Response
20
     */
21 View Code Duplication
    public function index(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...
22
    {
23
        // fetch devices from the database
24
        if ($request->user()->level >= 10 || $request->user()->level == 5) {
25
            $devices = Device::all();
26
        }
27
        else {
28
            $devices = User::find($request->user()->user_id)->devices()->get();
29
        }
30
        // morph the data as required
31
        if ($request->query('displayFormat') == 'human') {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
32
        }
33
34
       return $devices;
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  \Illuminate\Http\Request  $request
51
     * @return \Illuminate\Http\Response
52
     */
53
    public function store(Request $request)
1 ignored issue
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...
54
    {
55
        //
56
    }
57
58
    /**
59
     * Display the specified resource.
60
     *
61
     * @param  int  $id
62
     * @return \Illuminate\Http\Response
63
     */
64 View Code Duplication
    public function show(Request $request, $id)
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...
65
    {
66
        if ($request->user()->level >= 10 || $request->user()->level == 5) {
67
            return Device::find($id);
68
        }
69
        else {
70
            $user = User::find($request->user()->user_id);
71
            return $user->devices()->find($id);
72
        }
73
    }
74
75
    /**
76
     * Show the form for editing the specified resource.
77
     *
78
     * @param  int  $id
79
     * @return \Illuminate\Http\Response
80
     */
81
    public function edit($id)
1 ignored issue
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...
82
    {
83
        //
84
    }
85
86
    /**
87
     * Update the specified resource in storage.
88
     *
89
     * @param  \Illuminate\Http\Request  $request
90
     * @param  int  $id
91
     * @return \Illuminate\Http\Response
92
     */
93
    public function update(Request $request, $id)
2 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...
94
    {
95
        //
96
    }
97
98
    /**
99
     * Remove the specified resource from storage.
100
     *
101
     * @param  int  $id
102
     * @return \Illuminate\Http\Response
103
     */
104
    public function destroy($id)
1 ignored issue
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...
105
    {
106
        //
107
    }
108
109
}
110