Completed
Push — master ( 72cf95...b4fc03 )
by Artem
08:38
created

Options::setCollapseKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the FirebaseCloudMessagingBundle
4
 *
5
 * (c) Artem Henvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace Fresh\FirebaseCloudMessagingBundle\Message\Part\Options;
14
15
/**
16
 * Class Options.
17
 *
18
 * Set of options that can be used to change default behaviour of FCM notification.
19
 *
20
 * @author Artem Henvald <[email protected]>
21
 */
22
final class Options implements OptionsInterface
23
{
24
    /**
25
     * Default `time_to_live` option value is 4 weeks (it is also the maximum TTL allowed for FCM).
26
     * In seconds it is 60 seconds * 60 minutes * 24 hours * 28 days = 2419200 seconds.
27
     */
28
    public const DEFAULT_TTL_IN_SECONDS = 2419200;
29
30
    /** @var string */
31
    private $collapseKey = '';
32
33
    /** @var string */
34
    private $priority = Priority::NORMAL;
35
36
    /** @var bool */
37
    private $contentAvailable = false;
38
39
    /** @var int */
40
    private $ttl = self::DEFAULT_TTL_IN_SECONDS;
41
42
    /** @var string */
43
    private $restrictedPackageName = '';
44
45
    /** @var bool */
46
    private $dryRun = false;
47
48
    /**
49
     * @param string $collapseKey
50
     *
51
     * @return $this
52
     */
53
    public function setCollapseKey(string $collapseKey): self
54
    {
55
        $this->collapseKey = $collapseKey;
56
57
        return $this;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getCollapseKey(): string
64
    {
65
        return $this->collapseKey;
66
    }
67
68
    /**
69
     * @param string $priority
70
     *
71
     * @return $this
72
     */
73
    public function setPriority(string $priority): self
74
    {
75
        $this->priority = $priority;
76
77
        return $this;
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function getPriority(): string
84
    {
85
        return $this->priority;
86
    }
87
88
    /**
89
     * @param bool $contentAvailable
90
     *
91
     * @return $this
92
     */
93
    public function setContentAvailable(bool $contentAvailable): self
94
    {
95
        $this->contentAvailable = $contentAvailable;
96
97
        return $this;
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    public function isContentAvailable(): bool
104
    {
105
        return $this->contentAvailable;
106
    }
107
108
    /**
109
     * @param int $timeToLive
110
     *
111
     * @return $this
112
     */
113
    public function setTimeToLive(int $timeToLive): self
114
    {
115
        $this->ttl = $timeToLive;
116
117
        return $this;
118
    }
119
120
    /**
121
     * {@inheritdoc}
122
     */
123
    public function getTimeToLive(): int
124
    {
125
        return $this->ttl;
126
    }
127
128
    /**
129
     * @param string $restrictedPackageName
130
     *
131
     * @return $this
132
     */
133
    public function setRestrictedPackageName(string $restrictedPackageName): self
134
    {
135
        $this->restrictedPackageName = $restrictedPackageName;
136
137
        return $this;
138
    }
139
140
    /**
141
     * {@inheritdoc}
142
     */
143
    public function getRestrictedPackageName(): string
144
    {
145
        return $this->restrictedPackageName;
146
    }
147
148
    /**
149
     * @param bool $dryRun
150
     *
151
     * @return $this
152
     */
153
    public function setDryRun(bool $dryRun): self
154
    {
155
        $this->dryRun = $dryRun;
156
157
        return $this;
158
    }
159
160
    /**
161
     * {@inheritdoc}
162
     */
163
    public function isDryRun(): bool
164
    {
165
        return $this->dryRun;
166
    }
167
}
168