Passed
Push — master ( fa19ce...ad6694 )
by Alex
03:36
created

SectionRequest::show()   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
eloc 2
dl 0
loc 5
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Axsor\PhpIPAM\Http\Requests;
4
5
class SectionRequest extends Connector
6
{
7
    public function index()
8
    {
9
        return $this->get("sections");
10
    }
11
12
    public function show($section)
13
    {
14
        $id = get_id_from_variable($section);
15
16
        return $this->get("sections/{$id}");
17
    }
18
19
    public function subnets($section)
20
    {
21
        $id = get_id_from_variable($section);
22
23
        return $this->get("sections/{$id}/subnets");
24
    }
25
26
    public function byName(string $section)
27
    {
28
        return $this->get("sections/{$section}");
29
    }
30
31
    // TODO upgrade PhpIPAM from 1.3 to 1.5
32
    //public function customFields()
33
    //{
34
    //    return $this->get("sections/custom_fields");
35
    //}
36
37
    public function create(array $section)
38
    {
39
        return $this->post("sections", $section);
40
    }
41
42
    public function update($section, array $newData)
43
    {
44
        $id = get_id_from_variable($section);
45
46
        return $this->patch("sections/{$id}", $newData);
47
    }
48
49
    public function drop($section)
50
    {
51
        $id = get_id_from_variable($section);
52
53
        return $this->delete("sections/{$id}");
54
    }
55
}
56