Passed
Push — master ( f9c14b...c6fe8b )
by Laurens
02:03
created

Camera::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 14
dl 0
loc 30
ccs 15
cts 15
cp 1
crap 1
rs 9.44
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\Camera\Event;
9
10
final class Camera
11
{
12
    /**
13
     * @var string
14
     */
15
    private $deviceId;
16
17
    /**
18
     * @var string
19
     */
20
    private $structureId;
21
22
    /**
23
     * @var string
24
     */
25
    private $whereId;
26
27
    /**
28
     * @var string
29
     */
30
    private $name;
31
32
    /**
33
     * @var string
34
     */
35
    private $nameLong;
36
37
    /**
38
     * @var string
39
     */
40
    private $softwareVersion;
41
42
    /**
43
     * @var bool
44
     */
45
    private $online;
46
47
    /**
48
     * @var bool
49
     */
50
    private $streaming;
51
52
    /**
53
     * @var bool
54
     */
55
    private $audioInputEnabled;
56
57
    /**
58
     * @var DateTimeImmutable
59
     */
60
    private $lastIsOnlineChange;
61
62
    /**
63
     * @var bool
64
     */
65
    private $videoHistoryEnabled;
66
67
    /**
68
     * @var null|Event
69
     */
70
    private $lastEvent;
71
72
    /**
73
     * @var string
74
     */
75
    private $webUrl;
76
77
    /**
78
     * @var string
79
     */
80
    private $appUrl;
81
82 4
    public function __construct(
83
        string $deviceId,
84
        string $structureId,
85
        string $whereId,
86
        string $name,
87
        string $nameLong,
88
        string $softwareVersion,
89
        bool $online,
90
        bool $streaming,
91
        bool $audioInputEnabled,
92
        DateTimeImmutable $lastIsOnlineChange,
93
        bool $videoHistoryEnabled,
94
        ?Event $lastEvent,
95
        string $webUrl,
96
        string $appUrl
97
    ) {
98 4
        $this->deviceId = $deviceId;
99 4
        $this->structureId = $structureId;
100 4
        $this->whereId = $whereId;
101 4
        $this->name = $name;
102 4
        $this->nameLong = $nameLong;
103 4
        $this->softwareVersion = $softwareVersion;
104 4
        $this->online = $online;
105 4
        $this->streaming = $streaming;
106 4
        $this->audioInputEnabled = $audioInputEnabled;
107 4
        $this->lastIsOnlineChange = $lastIsOnlineChange;
108 4
        $this->videoHistoryEnabled = $videoHistoryEnabled;
109 4
        $this->lastEvent = $lastEvent;
110 4
        $this->webUrl = $webUrl;
111 4
        $this->appUrl = $appUrl;
112 4
    }
113
114 2
    public function getDeviceId(): string
115
    {
116 2
        return $this->deviceId;
117
    }
118
119
    public function getStructureId(): string
120
    {
121
        return $this->structureId;
122
    }
123
124
    public function getWhereId(): string
125
    {
126
        return $this->whereId;
127
    }
128
129 2
    public function getName(): string
130
    {
131 2
        return $this->name;
132
    }
133
134
    public function getNameLong(): string
135
    {
136
        return $this->nameLong;
137
    }
138
139
    public function getSoftwareVersion(): string
140
    {
141
        return $this->softwareVersion;
142
    }
143
144
    public function isOnline(): bool
145
    {
146
        return $this->online;
147
    }
148
149
    public function isStreaming(): bool
150
    {
151
        return $this->streaming;
152
    }
153
154
    public function isAudioInputEnabled(): bool
155
    {
156
        return $this->audioInputEnabled;
157
    }
158
159
    public function getLastIsOnlineChange(): DateTimeImmutable
160
    {
161
        return $this->lastIsOnlineChange;
162
    }
163
164
    public function isVideoHistoryEnabled(): bool
165
    {
166
        return $this->videoHistoryEnabled;
167
    }
168
169
    public function getLastEvent(): ?Event
170
    {
171
        return $this->lastEvent;
172
    }
173
174
    public function getWebUrl(): string
175
    {
176
        return $this->webUrl;
177
    }
178
179
    public function getAppUrl(): string
180
    {
181
        return $this->appUrl;
182
    }
183
}
184