Passed
Push — master ( a73698...779072 )
by Alex
06:49 queued 13s
created

ToolController::locationDrop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Axsor\PhpIPAM\Http\Controllers;
4
5
use Axsor\PhpIPAM\Http\Requests\ToolRequest;
6
use Axsor\PhpIPAM\Models\Location;
7
8
class ToolController
9
{
10
    protected $request;
11
12
    public function __construct()
13
    {
14
        $this->request = new ToolRequest();
15
    }
16
17
    public function locations()
18
    {
19
        $response = $this->request->locations();
20
21
        return response_to_collect($response, Location::class);
22
    }
23
24
    public function location($location)
25
    {
26
        $response = $this->request->location($location);
27
28
        return new Location($response['data']);
29
    }
30
31
    public function locationCreate(array $location)
32
    {
33
        $response = $this->request->locationCreate($location);
34
35
        return get_key_or_null($response, 'id');
36
    }
37
38
    public function locationUpdate($location, array $newData)
39
    {
40
        $response = $this->request->locationUpdate($location, $newData);
41
42
        return (bool) $response['success'];
43
    }
44
45
    public function locationDrop($location)
46
    {
47
        $response = $this->request->locationDrop($location);
48
49
        return (bool) $response['success'];
50
    }
51
}
52