Test Failed
Push — master ( e66f09...2b1c87 )
by Laurens
03:56
created

Structure::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 9
dl 0
loc 20
ccs 0
cts 10
cp 0
crap 2
rs 9.6
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\ProtectProxy;
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 ProtectProxy[]
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
    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
        $this->structureId = $structureId;
72
        $this->name = $name;
73
        $this->thermostats = $thermostats;
74
        $this->smokeCoAlarms = $smokeCoAlarms;
75
        $this->cameras = $cameras;
76
        $this->countryCode = $countryCode;
77
        $this->timeZone = $timeZone;
78
        $this->away = $away;
79
        $this->rhrEnrollment = $rhrEnrollment;
80
    }
81
82
    public function getStructureId(): string
83
    {
84
        return $this->structureId;
85
    }
86
87
    public function getName(): string
88
    {
89
        return $this->name;
90
    }
91
92
    /**
93
     * @return ThermostatProxy[]
94
     */
95
    public function getThermostats(): array
96
    {
97
        return $this->thermostats;
98
    }
99
100
    /**
101
     * @return ProtectProxy[]
102
     */
103
    public function getProtects(): array
104
    {
105
        return $this->smokeCoAlarms;
106
    }
107
108
    /**
109
     * @return CameraProxy[]
110
     */
111
    public function getCameras(): array
112
    {
113
        return $this->cameras;
114
    }
115
116
    public function getCountryCode(): string
117
    {
118
        return $this->countryCode;
119
    }
120
121
    public function getTimeZone(): DateTimeZone
122
    {
123
        return $this->timeZone;
124
    }
125
126
    public function getAway(): Away
127
    {
128
        return $this->away;
129
    }
130
131
    public function isRhrEnrollment(): bool
132
    {
133
        return $this->rhrEnrollment;
134
    }
135
}
136