LightSettings::getColor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace NotificationChannels\Fcm\Resources;
4
5
class LightSettings implements FcmResource
6
{
7
    /**
8
     * @var Color
9
     */
10
    protected $color;
11
12
    /**
13
     * @var string|null
14
     */
15
    protected $lightOnDuration;
16
17
    /**
18
     * @var string|null
19
     */
20
    protected $lightOffDuration;
21
22
    /**
23
     * @return static
24
     */
25
    public static function create(): self
26
    {
27
        return new self;
28
    }
29
30
    /**
31
     * @return Color
32
     */
33
    public function getColor(): Color
34
    {
35
        return $this->color;
36
    }
37
38
    /**
39
     * @param Color $color
40
     * @return LightSettings
41
     */
42
    public function setColor(Color $color): self
43
    {
44
        $this->color = $color;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @return string|null
51
     */
52
    public function getLightOnDuration(): ?string
53
    {
54
        return $this->lightOnDuration;
55
    }
56
57
    /**
58
     * @param string|null $lightOnDuration
59
     * @return LightSettings
60
     */
61
    public function setLightOnDuration(?string $lightOnDuration): self
62
    {
63
        $this->lightOnDuration = $lightOnDuration;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @return string|null
70
     */
71
    public function getLightOffDuration(): ?string
72
    {
73
        return $this->lightOffDuration;
74
    }
75
76
    /**
77
     * @param string|null $lightOffDuration
78
     * @return LightSettings
79
     */
80
    public function setLightOffDuration(?string $lightOffDuration): self
81
    {
82
        $this->lightOffDuration = $lightOffDuration;
83
84
        return $this;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function toArray(): array
91
    {
92
        return [
93
            'color' => ! is_null($this->getColor()) ? $this->getColor()->toArray() : null,
94
            'light_on_duration' => $this->getLightOnDuration(),
95
            'light_off_duration' => $this->getLightOffDuration(),
96
        ];
97
    }
98
}
99