SmokeCoAlarm::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 15
dl 0
loc 32
ccs 16
cts 16
cp 1
crap 1
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 5
    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 5
        $this->deviceId = $deviceId;
107 5
        $this->whereId = $whereId;
108 5
        $this->structureId = $structureId;
109 5
        $this->name = $name;
110 5
        $this->nameLong = $nameLong;
111 5
        $this->locale = $locale;
112 5
        $this->softwareVersion = $softwareVersion;
113 5
        $this->online = $online;
114 5
        $this->lastConnection = $lastConnection;
115 5
        $this->batteryHealth = $batteryHealth;
116 5
        $this->coAlarmState = $coAlarmState;
117 5
        $this->smokeAlarmState = $smokeAlarmState;
118 5
        $this->uiColorState = $uiColorState;
119 5
        $this->manualTestActive = $manualTestActive;
120 5
        $this->lastManualTest = $lastManualTest;
121 5
    }
122
123 3
    public function getDeviceId(): string
124
    {
125 3
        return $this->deviceId;
126
    }
127
128 1
    public function getWhereId(): string
129
    {
130 1
        return $this->whereId;
131
    }
132
133 1
    public function getStructureId(): string
134
    {
135 1
        return $this->structureId;
136
    }
137
138 3
    public function getName(): string
139
    {
140 3
        return $this->name;
141
    }
142
143 1
    public function getNameLong(): string
144
    {
145 1
        return $this->nameLong;
146
    }
147
148 1
    public function getLocale(): string
149
    {
150 1
        return $this->locale;
151
    }
152
153 1
    public function getSoftwareVersion(): string
154
    {
155 1
        return $this->softwareVersion;
156
    }
157
158 1
    public function isOnline(): bool
159
    {
160 1
        return $this->online;
161
    }
162
163 1
    public function getLastConnection(): ?DateTimeImmutable
164
    {
165 1
        return $this->lastConnection;
166
    }
167
168 1
    public function getBatteryHealth(): BatteryHealth
169
    {
170 1
        return $this->batteryHealth;
171
    }
172
173 1
    public function getCoAlarmState(): AlarmState
174
    {
175 1
        return $this->coAlarmState;
176
    }
177
178 1
    public function getSmokeAlarmState(): AlarmState
179
    {
180 1
        return $this->smokeAlarmState;
181
    }
182
183 1
    public function getUiColorState(): UiColorState
184
    {
185 1
        return $this->uiColorState;
186
    }
187
188 1
    public function isManualTestActive(): bool
189
    {
190 1
        return $this->manualTestActive;
191
    }
192
193 1
    public function getLastManualTest(): DateTimeImmutable
194
    {
195 1
        return $this->lastManualTest;
196
    }
197
}
198