Completed
Push — master ( 0d4684...fff311 )
by Chris
01:24
created

AndroidConfig::getRestrictedPackageName()   A

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 AndroidConfig implements FcmResource
6
{
7
    /**
8
     * @var string|null
9
     */
10
    protected $collapseKey;
11
12
    /**
13
     * @var AndroidMessagePriority|null
14
     */
15
    protected $priority;
16
17
    /**
18
     * @var string|null
19
     */
20
    protected $ttl;
21
22
    /**
23
     * @var string|null
24
     */
25
    protected $restrictedPackageName;
26
27
    /**
28
     * @var array|null
29
     */
30
    protected $data;
31
32
    /**
33
     * @var AndroidNotification|null
34
     */
35
    protected $notification;
36
37
    /**
38
     * @var AndroidFcmOptions|null
39
     */
40
    protected $fcmOptions;
41
42
    /**
43
     * @return static
44
     */
45
    public static function create(): self
46
    {
47
        return new self;
48
    }
49
50
    /**
51
     * @return string|null
52
     */
53
    public function getCollapseKey(): ?string
54
    {
55
        return $this->collapseKey;
56
    }
57
58
    /**
59
     * @param string|null $collapseKey
60
     * @return AndroidConfig
61
     */
62
    public function setCollapseKey(?string $collapseKey): self
63
    {
64
        $this->collapseKey = $collapseKey;
65
66
        return $this;
67
    }
68
69
    /**
70
     * @return AndroidMessagePriority|null
71
     */
72
    public function getPriority(): ?AndroidMessagePriority
73
    {
74
        return $this->priority;
75
    }
76
77
    /**
78
     * @param AndroidMessagePriority|null $priority
79
     * @return AndroidConfig
80
     */
81
    public function setPriority(?AndroidMessagePriority $priority): self
82
    {
83
        $this->priority = $priority;
84
85
        return $this;
86
    }
87
88
    /**
89
     * @return string|null
90
     */
91
    public function getTtl(): ?string
92
    {
93
        return $this->ttl;
94
    }
95
96
    /**
97
     * @param string|null $ttl
98
     * @return AndroidConfig
99
     */
100
    public function setTtl(?string $ttl): self
101
    {
102
        $this->ttl = $ttl;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @return string|null
109
     */
110
    public function getRestrictedPackageName(): ?string
111
    {
112
        return $this->restrictedPackageName;
113
    }
114
115
    /**
116
     * @param string|null $restrictedPackageName
117
     * @return AndroidConfig
118
     */
119
    public function setRestrictedPackageName(?string $restrictedPackageName): self
120
    {
121
        $this->restrictedPackageName = $restrictedPackageName;
122
123
        return $this;
124
    }
125
126
    /**
127
     * @return array|null
128
     */
129
    public function getData(): ?array
130
    {
131
        return $this->data;
132
    }
133
134
    /**
135
     * @param array|null $data
136
     * @return AndroidConfig
137
     */
138
    public function setData(?array $data): self
139
    {
140
        $this->data = $data;
141
142
        return $this;
143
    }
144
145
    /**
146
     * @return AndroidNotification|null
147
     */
148
    public function getNotification(): ?AndroidNotification
149
    {
150
        return $this->notification;
151
    }
152
153
    /**
154
     * @param AndroidNotification|null $notification
155
     * @return AndroidConfig
156
     */
157
    public function setNotification(?AndroidNotification $notification): self
158
    {
159
        $this->notification = $notification;
160
161
        return $this;
162
    }
163
164
    /**
165
     * @return AndroidFcmOptions|null
166
     */
167
    public function getFcmOptions(): ?AndroidFcmOptions
168
    {
169
        return $this->fcmOptions;
170
    }
171
172
    /**
173
     * @param AndroidFcmOptions|null $fcmOptions
174
     * @return AndroidConfig
175
     */
176
    public function setFcmOptions(?AndroidFcmOptions $fcmOptions): self
177
    {
178
        $this->fcmOptions = $fcmOptions;
179
180
        return $this;
181
    }
182
183
    /**
184
     * {@inheritdoc}
185
     */
186
    public function toArray(): array
187
    {
188
        return [
189
            'collapse_key' => $this->getCollapseKey(),
190
            'priority' => ! is_null($this->getPriority()) ? $this->getPriority()->getValue() : null,
191
            'ttl' => $this->getTtl(),
192
            'restricted_package_name' => $this->getRestrictedPackageName(),
193
            'data' => $this->getData(),
194
            'notification' => ! is_null($this->getNotification()) ? $this->getNotification()->toArray() : null,
195
            'fcm_options' => ! is_null($this->getFcmOptions()) ? $this->getFcmOptions()->toArray() : null,
196
        ];
197
    }
198
}
199