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

Endpoint::hasPayload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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