DnsRecordsTest::getRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
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\Tests\Requests;
24
25
use RossMitchell\UpdateCloudFlare\Data\IpType;
26
use RossMitchell\UpdateCloudFlare\Factories\Requests\DnsRecordsFactory;
27
28
/**
29
 * Class DnsRecordsTest
30
 * @package RossMitchell\UpdateCloudFlare\Tests\Requests
31
 */
32
class DnsRecordsTest extends AbstractRequest
33
{
34
    /**
35
     * @Inject
36
     * @var DnsRecordsFactory
37
     */
38
    private $dnsRecords;
39
40
    private $subDomain = 'www';
41
    private $type      = IpType::IP_V4;
42
    private $zoneId    = '12345';
43
44
45
    /**
46
     * @return mixed
47
     */
48
    public function getRequest()
49
    {
50
        return $this->dnsRecords->create($this->subDomain, $this->type, $this->zoneId);
51
    }
52
53
    /**
54
     * @return array
55
     */
56
    public function getHeaders(): array
57
    {
58
        return [
59
            'X-Auth-Email: [email protected]',
60
            'X-Auth-Key: 123456789',
61
            'Content-Type: application/json',
62
        ];
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getRequestType(): string
69
    {
70
        return 'GET';
71
    }
72
73
    /**
74
     * @return array
75
     */
76
    public function getFields(): array
77
    {
78
        return [];
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getUrl(): string
85
    {
86
        $zoneId = $this->zoneId;
87
        $type   = $this->type;
88
        $domain = $this->subDomain . '.example.com';
89
90
        return "https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records?type=${type}&name=${domain}";
91
    }
92
}
93