ZoneInfo::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 *
5
 * Copyright (C) 2018  Ross Mitchell
6
 *
7
 * This file is part of RossMitchell/UpdateCloudFlare.
8
 *
9
 * RossMitchell/UpdateCloudFlare is free software: you can redistribute
10
 * it and/or modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
namespace RossMitchell\UpdateCloudFlare\Requests;
24
25
use RossMitchell\UpdateCloudFlare\Interfaces\ConfigInterface;
26
use RossMitchell\UpdateCloudFlare\Interfaces\HeadersInterface;
27
use RossMitchell\UpdateCloudFlare\Interfaces\RequestInterface;
28
29
/**
30
 * This is used to get the zone information for the base domain
31
 *
32
 * @package RossMitchell\UpdateCloudFlare
33
 */
34
class ZoneInfo implements RequestInterface
35
{
36
    /**
37
     * @var ConfigInterface
38
     */
39
    private $config;
40
    /**
41
     * @var HeadersInterface
42
     */
43
    private $headers;
44
45
    /**
46
     * ZoneInfo constructor.
47
     *
48
     * @param ConfigInterface  $config
49
     * @param HeadersInterface $headers
50
     */
51 8
    public function __construct(ConfigInterface $config, HeadersInterface $headers)
52
    {
53 8
        $this->config  = $config;
54 8
        $this->headers = $headers;
55 8
    }
56
57
    /**
58
     * If headers need to be sent through then they can be returned with this method. If not return an empty array
59
     *
60
     * @return array
61
     */
62 1
    public function getHeaders(): array
63
    {
64 1
        return $this->headers->getHeadersArray();
65
    }
66
67
    /**
68
     * They type of request that is going to be made
69
     *
70
     * @return string
71
     */
72 1
    public function getRequestType(): string
73
    {
74 1
        return 'GET';
75
    }
76
77
    /**
78
     * If the request needs data to be sent though return it here. If not return an empty array
79
     *
80
     * @return array
81
     */
82 1
    public function getFields(): array
83
    {
84 1
        return [];
85
    }
86
87
    /**
88
     * Return the URL that the request should be made to
89
     *
90
     * @return string
91
     */
92 1
    public function getUrl(): string
93
    {
94 1
        $baseUrl = $this->config->getApiUrl();
95 1
        $domain  = $this->config->getBaseUrl();
96
97
        return "${baseUrl}zones?name=${domain}";
98
    }
99
}
100