SubDomainInfo::getZoneId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
crap 2
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\Data;
24
25
use Symfony\Component\Console\Exception\LogicException;
26
27
/**
28
 * Class SubDomainInfo
29
 * @package RossMitchell\UpdateCloudFlare\Data
30
 */
31
class SubDomainInfo
32
{
33
    /**
34
     * @var string
35
     */
36
    private $ipAddress;
37
    /**
38
     * @var string
39
     */
40
    private $subDomain;
41
    /**
42
     * @var IpType
43
     */
44
    private $ipType;
45
    /**
46
     * @var string
47
     */
48
    private $subDomainId;
49
    /**
50
     * @var string
51
     */
52
    private $zoneId;
53
54
    /**
55
     * SubDomainInfo constructor.
56
     *
57
     * @param string $subDomain
58
     * @param IpType $ipType
59
     */
60 31
    public function __construct(string $subDomain, IpType $ipType)
61
    {
62 31
        $this->subDomain = $subDomain;
63 31
        $this->ipType    = $ipType;
64 31
    }
65
66
    /**
67
     * @return string
68
     * @throws LogicException
69
     */
70 5
    public function getIpAddress(): string
71
    {
72 5
        if ($this->ipAddress === null) {
73 1
            $this->throwException('IP Address');
74
        }
75
76 4
        return $this->ipAddress;
77
    }
78
79
    /**
80
     * @param string $ipAddress
81
     */
82 10
    public function setIpAddress(string $ipAddress): void
83
    {
84 10
        $this->ipAddress = $ipAddress;
85 10
    }
86
87
    /**
88
     * @return string
89
     */
90 4
    public function getSubDomain(): string
91
    {
92 4
        return $this->subDomain;
93
    }
94
95
    /**
96
     * @return string
97
     */
98 4
    public function getIpType(): string
99
    {
100 4
        return $this->ipType->getType();
101
    }
102
103
    /**
104
     * @return string
105
     * @throws LogicException
106
     */
107 3
    public function getSubDomainId(): string
108
    {
109 3
        if ($this->subDomainId === null) {
110 1
            $this->throwException('sub domain ID');
111
        }
112
113 2
        return $this->subDomainId;
114
    }
115
116
    /**
117
     * @param string $subDomainId
118
     */
119 10
    public function setSubDomainId(string $subDomainId): void
120
    {
121 10
        $this->subDomainId = $subDomainId;
122 10
    }
123
124
    /**
125
     * @return string
126
     * @throws LogicException
127
     */
128 5
    public function getZoneId(): string
129
    {
130 5
        if ($this->zoneId === null) {
131 1
            $this->throwException('Zone ID');
132
        }
133
134 4
        return $this->zoneId;
135
    }
136
137
    /**
138
     * @param string $zoneId
139
     */
140 20
    public function setZoneId(string $zoneId): void
141
    {
142 20
        $this->zoneId = $zoneId;
143 20
    }
144
145
    /**
146
     * @param string $missingProperty
147
     *
148
     * @throws \Symfony\Component\Console\Exception\LogicException
149
     */
150 3
    private function throwException(string $missingProperty): void
151
    {
152 3
        throw new LogicException("You must set the $missingProperty");
153
    }
154
}
155