Camera::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 14
dl 0
loc 30
ccs 15
cts 15
cp 1
crap 1
rs 9.7998
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 6
    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 6
        $this->deviceId = $deviceId;
99 6
        $this->structureId = $structureId;
100 6
        $this->whereId = $whereId;
101 6
        $this->name = $name;
102 6
        $this->nameLong = $nameLong;
103 6
        $this->softwareVersion = $softwareVersion;
104 6
        $this->online = $online;
105 6
        $this->streaming = $streaming;
106 6
        $this->audioInputEnabled = $audioInputEnabled;
107 6
        $this->lastIsOnlineChange = $lastIsOnlineChange;
108 6
        $this->videoHistoryEnabled = $videoHistoryEnabled;
109 6
        $this->lastEvent = $lastEvent;
110 6
        $this->webUrl = $webUrl;
111 6
        $this->appUrl = $appUrl;
112 6
    }
113
114 4
    public function getDeviceId(): string
115
    {
116 4
        return $this->deviceId;
117
    }
118
119 2
    public function getStructureId(): string
120
    {
121 2
        return $this->structureId;
122
    }
123
124 2
    public function getWhereId(): string
125
    {
126 2
        return $this->whereId;
127
    }
128
129 4
    public function getName(): string
130
    {
131 4
        return $this->name;
132
    }
133
134 2
    public function getNameLong(): string
135
    {
136 2
        return $this->nameLong;
137
    }
138
139 2
    public function getSoftwareVersion(): string
140
    {
141 2
        return $this->softwareVersion;
142
    }
143
144 2
    public function isOnline(): bool
145
    {
146 2
        return $this->online;
147
    }
148
149 2
    public function isStreaming(): bool
150
    {
151 2
        return $this->streaming;
152
    }
153
154 2
    public function isAudioInputEnabled(): bool
155
    {
156 2
        return $this->audioInputEnabled;
157
    }
158
159 2
    public function getLastIsOnlineChange(): DateTimeImmutable
160
    {
161 2
        return $this->lastIsOnlineChange;
162
    }
163
164 2
    public function isVideoHistoryEnabled(): bool
165
    {
166 2
        return $this->videoHistoryEnabled;
167
    }
168
169 2
    public function getLastEvent(): ?Event
170
    {
171 2
        return $this->lastEvent;
172
    }
173
174 2
    public function getWebUrl(): string
175
    {
176 2
        return $this->webUrl;
177
    }
178
179 2
    public function getAppUrl(): string
180
    {
181 2
        return $this->appUrl;
182
    }
183
}
184