Passed
Push — master ( 941e97...ba9899 )
by Ross
02:32
created

SubDomainInfo::throwException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 1
nc 1
nop 1
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\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
     * @return string
56
     * @throws LogicException
57
     */
58 2
    public function getIpAddress(): string
59
    {
60 2
        if ($this->ipAddress === null) {
61 1
            $this->throwException('IP Address');
62
        }
63
64 1
        return $this->ipAddress;
65
    }
66
67
    /**
68
     * @param string $ipAddress
69
     */
70 1
    public function setIpAddress(string $ipAddress)
71
    {
72 1
        $this->ipAddress = $ipAddress;
73 1
    }
74
75
    /**
76
     * @return string
77
     * @throws LogicException
78
     */
79 2
    public function getSubDomain(): string
80
    {
81 2
        if ($this->subDomain === null) {
82 1
            $this->throwException('sub domain');
83
        }
84
85 1
        return $this->subDomain;
86
    }
87
88
    /**
89
     * @param string $subDomain
90
     */
91 1
    public function setSubDomain(string $subDomain)
92
    {
93 1
        $this->subDomain = $subDomain;
94 1
    }
95
96
    /**
97
     * @return string
98
     * @throws LogicException
99
     */
100 2
    public function getIpType(): string
101
    {
102 2
        if ($this->ipType === null) {
103 1
            $this->throwException('IP Type');
104
        }
105
106 1
        return $this->ipType->getType();
107
    }
108
109
    /**
110
     * @param IpType $ipType
111
     */
112 1
    public function setIpType(IpType $ipType)
113
    {
114 1
        $this->ipType = $ipType;
115 1
    }
116
117
    /**
118
     * @return string
119
     * @throws LogicException
120
     */
121 2
    public function getSubDomainId(): string
122
    {
123 2
        if ($this->subDomainId === null) {
124 1
            $this->throwException('sub domain ID');
125
        }
126 1
        return $this->subDomainId;
127
    }
128
129
    /**
130
     * @param string $subDomainId
131
     */
132 1
    public function setSubDomainId(string $subDomainId)
133
    {
134 1
        $this->subDomainId = $subDomainId;
135 1
    }
136
137
    /**
138
     * @return string
139
     * @throws LogicException
140
     */
141 2
    public function getZoneId(): string
142
    {
143 2
        if ($this->zoneId === null) {
144 1
            $this->throwException('Zone ID');
145
        }
146 1
        return $this->zoneId;
147
    }
148
149
    /**
150
     * @param string $zoneId
151
     */
152 1
    public function setZoneId(string $zoneId)
153
    {
154 1
        $this->zoneId = $zoneId;
155 1
    }
156
157
    /**
158
     * @param string $missingProperty
159
     */
160 5
    private function throwException(string $missingProperty)
161
    {
162 5
        throw new LogicException("You must set the $missingProperty");
163
    }
164
}
165