Passed
Branch master (6d737b)
by Laurens
01:46
created

Event::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 8
dl 0
loc 18
ccs 9
cts 9
cp 1
crap 1
rs 10
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\Camera;
6
7
use DateTimeImmutable;
8
9
final class Event
10
{
11
    /**
12
     * @var DateTimeImmutable
13
     */
14
    private $startTime;
15
16
    /**
17
     * @var DateTimeImmutable
18
     */
19
    private $endTime;
20
21
    /**
22
     * @var DateTimeImmutable
23
     */
24
    private $urlsExpireTime;
25
26
    /**
27
     * @var bool
28
     */
29
    private $sound;
30
31
    /**
32
     * @var bool
33
     */
34
    private $motion;
35
36
    /**
37
     * @var bool
38
     */
39
    private $person;
40
41
    /**
42
     * @var string
43
     */
44
    private $webUrl;
45
46
    /**
47
     * @var string
48
     */
49
    private $appUrl;
50
51 1
    public function __construct(
52
        DateTimeImmutable $startTime,
53
        DateTimeImmutable $endTime,
54
        DateTimeImmutable $urlsExpireTime,
55
        bool $sound,
56
        bool $motion,
57
        bool $person,
58
        string $webUrl,
59
        string $appUrl
60
    ) {
61 1
        $this->startTime = $startTime;
62 1
        $this->endTime = $endTime;
63 1
        $this->urlsExpireTime = $urlsExpireTime;
64 1
        $this->sound = $sound;
65 1
        $this->motion = $motion;
66 1
        $this->person = $person;
67 1
        $this->webUrl = $webUrl;
68 1
        $this->appUrl = $appUrl;
69 1
    }
70
71 1
    public function getStartTime(): DateTimeImmutable
72
    {
73 1
        return $this->startTime;
74
    }
75
76 1
    public function getEndTime(): DateTimeImmutable
77
    {
78 1
        return $this->endTime;
79
    }
80
81 1
    public function getUrlsExpireTime(): DateTimeImmutable
82
    {
83 1
        return $this->urlsExpireTime;
84
    }
85
86 1
    public function hasSound(): bool
87
    {
88 1
        return $this->sound;
89
    }
90
91 1
    public function hasMotion(): bool
92
    {
93 1
        return $this->motion;
94
    }
95
96 1
    public function hasPerson(): bool
97
    {
98 1
        return $this->person;
99
    }
100
101 1
    public function getWebUrl(): string
102
    {
103 1
        return $this->webUrl;
104
    }
105
106 1
    public function getAppUrl(): string
107
    {
108 1
        return $this->appUrl;
109
    }
110
}
111