Completed
Push — master ( 303176...154099 )
by Günter
10s
created

Endpoint   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getUri() 0 8 1
A getMethod() 0 4 1
A hasPayload() 0 4 1
A getPayload() 0 4 1
A appendToUri() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the africc/pdns-client library.
5
 *
6
 * (c) Gunter Grodotzki <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE file
9
 * that was distributed with this source code.
10
 */
11
12
namespace AfriCC\Pdns\Endpoints;
13
14
use AfriCC\Pdns\Helper;
15
16
abstract class Endpoint implements Endpointable
17
{
18
    protected $data;
19
20
    protected $method = 'GET';
21
22
    protected $appended_uri = '';
23
24
    public function getUri()
25
    {
26
        return sprintf(
27
            '/api/v1/servers/localhost/%s%s',
28
            strtolower(Helper::className($this)),
29
            $this->appended_uri
30
        );
31
    }
32
33
    public function getMethod()
34
    {
35
        return $this->method;
36
    }
37
38
    public function hasPayload()
39
    {
40
        return $this->data !== null;
41
    }
42
43
    public function getPayload()
44
    {
45
        return json_encode($this->data);
46
    }
47
48
    protected function appendToUri($uri)
49
    {
50
        $this->appended_uri = $uri;
51
    }
52
}
53