Completed
Push — master ( 2f2459...d82a91 )
by Ross
02:33
created

DnsRecordsFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 *
4
 * Copyright (C) 2018  Ross Mitchell
5
 *
6
 * This file is part of RossMitchell/UpdateCloudFlare.
7
 *
8
 * RossMitchell/UpdateCloudFlare is free software: you can redistribute
9
 * it and/or modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
namespace RossMitchell\UpdateCloudFlare\Factories\Requests;
23
24
use RossMitchell\UpdateCloudFlare\Factories\Data\SubDomainInfoFactory;
25
use RossMitchell\UpdateCloudFlare\Interfaces\ConfigInterface;
26
use RossMitchell\UpdateCloudFlare\Interfaces\HeadersInterface;
27
use RossMitchell\UpdateCloudFlare\Requests\DnsRecords;
28
29
class DnsRecordsFactory
30
{
31
    /**
32
     * @var SubDomainInfoFactory
33
     */
34
    private $subDomainInfoFactory;
35
    /**
36
     * @var ConfigInterface
37
     */
38
    private $config;
39
    /**
40
     * @var HeadersInterface
41
     */
42
    private $headers;
43
44
    /**
45
     * DnsRecordsFactory constructor.
46
     *
47
     * @param SubDomainInfoFactory $subDomainInfoFactory
48
     * @param ConfigInterface      $config
49
     * @param HeadersInterface     $headers
50
     */
51 7
    public function __construct(
52
        SubDomainInfoFactory $subDomainInfoFactory,
53
        ConfigInterface $config,
54
        HeadersInterface $headers
55
    ) {
56 7
        $this->subDomainInfoFactory = $subDomainInfoFactory;
57 7
        $this->config               = $config;
58 7
        $this->headers              = $headers;
59 7
    }
60
61
    /**
62
     * @param string $subDomainInfo
63
     * @param string $type
64
     * @param string $zoneId
65
     *
66
     * @return DnsRecords
67
     */
68 7
    public function create(string $subDomainInfo, string $type, string $zoneId): DnsRecords
69
    {
70 7
        $subDomainInfo = $this->subDomainInfoFactory->get($subDomainInfo, $type);
71 7
        $dnsRecord     = new DnsRecords($this->config, $this->headers);
72 7
        $subDomainInfo->setZoneId($zoneId);
73 7
        $dnsRecord->setSubDomainInfo($subDomainInfo);
74
75 7
        return $dnsRecord;
76
    }
77
}
78