Structure::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 9
dl 0
loc 20
ccs 10
cts 10
cp 1
crap 1
rs 9.9666
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;
6
7
use DateTimeZone;
8
use LauLamanApps\NestApi\Client\Structure\Away;
9
use LauLamanApps\NestApi\Client\Structure\CameraProxy;
10
use LauLamanApps\NestApi\Client\Structure\SmokeCoAlarmProxy;
11
use LauLamanApps\NestApi\Client\Structure\ThermostatProxy;
12
13
final class Structure
14
{
15
    /**
16
     * @var string
17
     */
18
    private $structureId;
19
20
    /**
21
     * @var string
22
     */
23
    private $name;
24
25
    /**
26
     * @var ThermostatProxy[]
27
     */
28
    private $thermostats;
29
30
    /**
31
     * @var SmokeCoAlarmProxy[]
32
     */
33
    private $smokeCoAlarms;
34
35
    /**
36
     * @var CameraProxy[]
37
     */
38
    private $cameras;
39
40
    /**
41
     * @var string
42
     */
43
    private $countryCode;
44
45
    /**
46
     * @var DateTimeZone
47
     */
48
    private $timeZone;
49
50
    /**
51
     * @var Away
52
     */
53
    private $away;
54
55
    /**
56
     * @var bool
57
     */
58
    private $rhrEnrollment;
59
60 5
    public function __construct(
61
        string $structureId,
62
        string $name,
63
        array $thermostats,
64
        array $smokeCoAlarms,
65
        array $cameras,
66
        string $countryCode,
67
        DateTimeZone $timeZone,
68
        Away $away,
69
        bool $rhrEnrollment
70
    ) {
71 5
        $this->structureId = $structureId;
72 5
        $this->name = $name;
73 5
        $this->thermostats = $thermostats;
74 5
        $this->smokeCoAlarms = $smokeCoAlarms;
75 5
        $this->cameras = $cameras;
76 5
        $this->countryCode = $countryCode;
77 5
        $this->timeZone = $timeZone;
78 5
        $this->away = $away;
79 5
        $this->rhrEnrollment = $rhrEnrollment;
80 5
    }
81
82 4
    public function getStructureId(): string
83
    {
84 4
        return $this->structureId;
85
    }
86
87 5
    public function getName(): string
88
    {
89 5
        return $this->name;
90
    }
91
92
    /**
93
     * @return ThermostatProxy[]
94
     */
95 2
    public function getThermostats(): array
96
    {
97 2
        return $this->thermostats;
98
    }
99
100
    /**
101
     * @return SmokeCoAlarmProxy[]
102
     */
103 2
    public function getSmokeCoAlarms(): array
104
    {
105 2
        return $this->smokeCoAlarms;
106
    }
107
108
    /**
109
     * @return CameraProxy[]
110
     */
111 2
    public function getCameras(): array
112
    {
113 2
        return $this->cameras;
114
    }
115
116 4
    public function getCountryCode(): string
117
    {
118 4
        return $this->countryCode;
119
    }
120
121 4
    public function getTimeZone(): DateTimeZone
122
    {
123 4
        return $this->timeZone;
124
    }
125
126 4
    public function getAway(): Away
127
    {
128 4
        return $this->away;
129
    }
130
131 4
    public function isRhrEnrollment(): bool
132
    {
133 4
        return $this->rhrEnrollment;
134
    }
135
}
136