Completed
Push — develop ( 5f1168...aa9d13 )
by Daniel
05:30
created

ApiController::list_ports()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4285
cc 3
eloc 5
nc 2
nop 1
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 ApiController extends Controller
11
{
12
    public function __construct() {
13
14
    }
15
16
    /**
17
     * Get a list of devices
18
     */
19 View Code Duplication
    public function list_devices(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...
20
        if ($request->user()->level >= 10 || $request->user()->level == 5) {
21
            return Device::all();
22
        }
23
        else {
24
            return User::find($request->user()->user_id)->devices()->get();
25
        }
26
    }
27
28
    /**
29
     * Get a list of ports
30
     */
31 View Code Duplication
    public function list_ports(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...
32
        if ($request->user()->level >= 10 || $request->user()->level == 5) {
33
            return Port::all();
34
        }
35
        else {
36
            return User::find($request->user()->user_id)->ports()->get();
37
        }
38
    }
39
}
40