Test Failed
Push — master ( 92951c...6d737b )
by Laurens
04:18
created

SmokeCoAlarm::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 15
dl 0
loc 32
rs 9.7666
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\NestApi\Client\Device;
6
7
use DateTimeImmutable;
8
use LauLamanApps\NestApi\Client\Device\SmokeCoAlarm\AlarmState;
9
use LauLamanApps\NestApi\Client\Device\SmokeCoAlarm\BatteryHealth;
10
use LauLamanApps\NestApi\Client\Device\SmokeCoAlarm\UiColorState;
11
12
final class SmokeCoAlarm
13
{
14
    /**
15
     * @var string
16
     */
17
    private $deviceId;
18
19
    /**
20
     * @var string
21
     */
22
    private $whereId;
23
24
    /**
25
     * @var string
26
     */
27
    private $structureId;
28
29
    /**
30
     * @var string
31
     */
32
    private $name;
33
34
    /**
35
     * @var string
36
     */
37
    private $nameLong;
38
39
    /**
40
     * @var string
41
     */
42
    private $locale;
43
44
    /**
45
     * @var string
46
     */
47
    private $softwareVersion;
48
49
    /**
50
     * @var bool
51
     */
52
    private $online;
53
54
    /**
55
     * @var ?DateTimeImmutable
56
     */
57
    private $lastConnection;
58
59
    /**
60
     * @var BatteryHealth
61
     */
62
    private $batteryHealth;
63
64
    /**
65
     * @var AlarmState
66
     */
67
    private $coAlarmState;
68
69
    /**
70
     * @var AlarmState
71
     */
72
    private $smokeAlarmState;
73
74
    /**
75
     * @var UiColorState
76
     */
77
    private $uiColorState;
78
79
    /**
80
     * @var bool
81
     */
82
    private $manualTestActive;
83
84
    /**
85
     * @var DateTimeImmutable
86
     */
87
    private $lastManualTest;
88
89
    public function __construct(
90
        string $deviceId,
91
        string $whereId,
92
        string $structureId,
93
        string $name,
94
        string $nameLong,
95
        string $locale,
96
        string $softwareVersion,
97
        bool $online,
98
        ?DateTimeImmutable $lastConnection = null,
99
        BatteryHealth $batteryHealth,
100
        AlarmState $coAlarmState,
101
        AlarmState $smokeAlarmState,
102
        UiColorState $uiColorState,
103
        bool $manualTestActive,
104
        DateTimeImmutable $lastManualTest
105
    ) {
106
        $this->deviceId = $deviceId;
107
        $this->whereId = $whereId;
108
        $this->structureId = $structureId;
109
        $this->name = $name;
110
        $this->nameLong = $nameLong;
111
        $this->locale = $locale;
112
        $this->softwareVersion = $softwareVersion;
113
        $this->online = $online;
114
        $this->lastConnection = $lastConnection;
115
        $this->batteryHealth = $batteryHealth;
116
        $this->coAlarmState = $coAlarmState;
117
        $this->smokeAlarmState = $smokeAlarmState;
118
        $this->uiColorState = $uiColorState;
119
        $this->manualTestActive = $manualTestActive;
120
        $this->lastManualTest = $lastManualTest;
121
    }
122
123
    public function getDeviceId(): string
124
    {
125
        return $this->deviceId;
126
    }
127
128
    public function getWhereId(): string
129
    {
130
        return $this->whereId;
131
    }
132
133
    public function getStructureId(): string
134
    {
135
        return $this->structureId;
136
    }
137
138
    public function getName(): string
139
    {
140
        return $this->name;
141
    }
142
143
    public function getNameLong(): string
144
    {
145
        return $this->nameLong;
146
    }
147
148
    public function getLocale(): string
149
    {
150
        return $this->locale;
151
    }
152
153
    public function getSoftwareVersion(): string
154
    {
155
        return $this->softwareVersion;
156
    }
157
158
    public function isOnline(): bool
159
    {
160
        return $this->online;
161
    }
162
163
    public function getLastConnection(): ?DateTimeImmutable
164
    {
165
        return $this->lastConnection;
166
    }
167
168
    public function getBatteryHealth(): BatteryHealth
169
    {
170
        return $this->batteryHealth;
171
    }
172
173
    public function getCoAlarmState(): AlarmState
174
    {
175
        return $this->coAlarmState;
176
    }
177
178
    public function getSmokeAlarmState(): AlarmState
179
    {
180
        return $this->smokeAlarmState;
181
    }
182
183
    public function getUiColorState(): UiColorState
184
    {
185
        return $this->uiColorState;
186
    }
187
188
    public function isManualTestActive(): bool
189
    {
190
        return $this->manualTestActive;
191
    }
192
193
    public function getLastManualTest(): DateTimeImmutable
194
    {
195
        return $this->lastManualTest;
196
    }
197
}
198