Passed
Push — master ( 396363...2462db )
by Alex
05:04 queued 01:36
created

AddressRequest   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 74
rs 10
wmc 12

12 Methods

Rating   Name   Duplication   Size   Complexity  
A tags() 0 3 1
A ping() 0 5 1
A show() 0 5 1
A customFields() 0 3 1
A create() 0 3 1
A tag() 0 5 1
A tagAddresses() 0 5 1
A byHostname() 0 3 1
A byIp() 0 3 1
A createFirstFree() 0 5 1
A drop() 0 5 1
A update() 0 5 1
1
<?php
2
3
namespace Axsor\PhpIPAM\Http\Requests;
4
5
class AddressRequest extends Connector
6
{
7
    public function show($address)
8
    {
9
        $id = get_id_from_variable($address);
10
11
        return $this->get("addresses/{$id}");
12
    }
13
14
    public function ping($address)
15
    {
16
        $id = get_id_from_variable($address);
17
18
        return $this->get("addresses/{$id}/ping");
19
    }
20
21
    public function byIp(string $ip)
22
    {
23
        return $this->get("addresses/search/{$ip}");
24
    }
25
26
    public function byHostname(string $hostname)
27
    {
28
        return $this->get("addresses/search_hostname/{$hostname}");
29
    }
30
31
    public function customFields()
32
    {
33
        return $this->get('addresses/custom_fields');
34
    }
35
36
    public function tags()
37
    {
38
        return $this->get('addresses/tags');
39
    }
40
41
    public function tag($tag)
42
    {
43
        $id = get_id_from_variable($tag);
44
45
        return $this->get("addresses/tags/{$id}");
46
    }
47
48
    public function tagAddresses($tag)
49
    {
50
        $id = get_id_from_variable($tag);
51
52
        return $this->get("addresses/tags/{$id}/addresses");
53
    }
54
55
    public function create(array $address)
56
    {
57
        return $this->post('addresses', $address);
58
    }
59
60
    public function createFirstFree($subnet)
61
    {
62
        $id = get_id_from_variable($subnet);
63
64
        return $this->post("addresses/first_free/{$id}", $subnet);
65
    }
66
67
    public function update($address, array $newData)
68
    {
69
        $id = get_id_from_variable($address);
70
71
        return $this->patch("addresses/{$id}", standarize_request_body($newData));
72
    }
73
74
    public function drop($address)
75
    {
76
        $id = get_id_from_variable($address);
77
78
        return $this->delete("addresses/{$id}");
79
    }
80
}
81