CircuitController::index()   A
last analyzed

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 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Axsor\PhpIPAM\Http\Controllers;
4
5
use Axsor\PhpIPAM\Http\Requests\CircuitRequest;
6
use Axsor\PhpIPAM\Models\Circuit;
7
8
class CircuitController
9
{
10
    protected $request;
11
12
    public function __construct()
13
    {
14
        $this->request = new CircuitRequest;
15
    }
16
17
    public function index()
18
    {
19
        $response = $this->request->index();
20
21
        return response_to_collect($response, Circuit::class);
22
    }
23
24
    public function show($circuit)
25
    {
26
        $response = $this->request->show($circuit);
27
28
        return new Circuit($response['data']);
29
    }
30
31
    public function create(array $circuit)
32
    {
33
        $response = $this->request->create($circuit);
34
35
        return get_key_or_null($response, 'id');
36
    }
37
38
    public function update($circuit, array $newData)
39
    {
40
        $response = $this->request->update($circuit, $newData);
41
42
        return (bool) $response['success'];
43
    }
44
45
    public function drop($circuit)
46
    {
47
        $response = $this->request->drop($circuit);
48
49
        return (bool) $response['success'];
50
    }
51
}
52