DeviceController   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 63
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A subnets() 0 5 1
A __construct() 0 3 1
A drop() 0 5 1
A show() 0 5 1
A addresses() 0 5 1
A index() 0 5 1
A create() 0 5 1
A types() 0 5 1
A update() 0 5 1
1
<?php
2
3
namespace Axsor\PhpIPAM\Http\Controllers;
4
5
use Axsor\PhpIPAM\Http\Requests\DeviceRequest;
6
use Axsor\PhpIPAM\Models\Address;
7
use Axsor\PhpIPAM\Models\Device;
8
use Axsor\PhpIPAM\Models\Subnet;
9
10
class DeviceController
11
{
12
    protected $request;
13
14
    public function __construct()
15
    {
16
        $this->request = new DeviceRequest;
17
    }
18
19
    public function index()
20
    {
21
        $response = $this->request->index();
22
23
        return response_to_collect($response, Device::class);
24
    }
25
26
    public function show($device)
27
    {
28
        $response = $this->request->show($device);
29
30
        return new Device($response['data']);
31
    }
32
33
    public function types($device)
0 ignored issues
show
Unused Code introduced by
The parameter $device is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public function types(/** @scrutinizer ignore-unused */ $device)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        $response = $this->request->types();
0 ignored issues
show
Bug introduced by
The method types() does not exist on Axsor\PhpIPAM\Http\Requests\DeviceRequest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        /** @scrutinizer ignore-call */ 
36
        $response = $this->request->types();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
37
        return response_to_collect($response, Device::class);
38
    }
39
40
    public function subnets($device)
41
    {
42
        $response = $this->request->subnets($device);
43
44
        return response_to_collect($response, Subnet::class);
45
    }
46
47
    public function addresses($device)
48
    {
49
        $response = $this->request->addresses($device);
50
51
        return response_to_collect($response, Address::class);
52
    }
53
54
    public function create(array $device)
55
    {
56
        $response = $this->request->create($device);
57
58
        return get_key_or_null($response, 'id');
59
    }
60
61
    public function update($device, array $newData)
62
    {
63
        $response = $this->request->update($device, $newData);
64
65
        return (bool) $response['success'];
66
    }
67
68
    public function drop($device)
69
    {
70
        $response = $this->request->drop($device);
71
72
        return (bool) $response['success'];
73
    }
74
}
75