GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#87)
by
unknown
06:16
created

WebPushMessage   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 261
Duplicated Lines 0 %

Coupling/Cohesion

Components 14
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 15
lcom 14
cbo 0
dl 0
loc 261
ccs 41
cts 41
cp 1
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A title() 0 6 1
A action() 0 6 1
A badge() 0 6 1
A body() 0 6 1
A dir() 0 6 1
A icon() 0 6 1
A image() 0 6 1
A lang() 0 6 1
A renotify() 0 6 1
A requireInteraction() 0 6 1
A tag() 0 6 1
A vibrate() 0 6 1
A data() 0 6 1
A options() 0 6 1
A toArray() 0 4 1
1
<?php
2
3
namespace NotificationChannels\WebPush;
4
5
/**
6
 * @link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification#Parameters
7
 */
8
class WebPushMessage
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $title;
14
15
    /**
16
     * @var array
17
     */
18
    protected $actions = [];
19
20
    /**
21
     * @var string
22
     */
23
    protected $badge;
24
25
    /**
26
     * @var string
27
     */
28
    protected $body;
29
30
    /**
31
     * @var string
32
     */
33
    protected $dir;
34
35
    /**
36
     * @var string
37
     */
38
    protected $icon;
39
40
    /**
41
     * @var string
42
     */
43
    protected $image;
44
45
    /**
46
     * @var string
47
     */
48
    protected $lang;
49
50
    /**
51
     * @var bool
52
     */
53
    protected $renotify;
54
55
    /**
56
     * @var bool
57
     */
58
    protected $requireInteraction;
59
60
    /**
61
     * @var string
62
     */
63
    protected $tag;
64
65
    /**
66
     * @var array
67
     */
68
    protected $vibrate;
69
70
    /**
71
     * @var mixed
72
     */
73
    protected $data;
74
75
    /**
76
     * @var mixed
77
     */
78
    protected $options;
79
80
    /**
81 3
     * Set the notification title.
82
     *
83 3
     * @param  string $value
84
     * @return $this
85 3
     */
86
    public function title($value)
87
    {
88
        $this->title = $value;
89
90
        return $this;
91
    }
92
93
    /**
94
     * Add a notification action.
95 3
     *
96
     * @param  string $title
97 3
     * @param  string $action
98
     * @return $this
99 3
     */
100
    public function action($title, $action)
101
    {
102
        $this->actions[] = compact('title', 'action');
103
104
        return $this;
105
    }
106
107
    /**
108 1
     * Set the notification badge.
109
     *
110 1
     * @param  string $value
111
     * @return $this
112 1
     */
113
    public function badge($value)
114
    {
115
        $this->badge = $value;
116
117
        return $this;
118
    }
119
120
    /**
121 3
     * Set the notification body.
122
     *
123 3
     * @param  string $value
124
     * @return $this
125 3
     */
126
    public function body($value)
127
    {
128
        $this->body = $value;
129
130
        return $this;
131
    }
132
133
    /**
134 1
     * Set the notification direction.
135
     *
136 1
     * @param  string $value
137
     * @return $this
138 1
     */
139
    public function dir($value)
140
    {
141
        $this->dir = $value;
142
143
        return $this;
144
    }
145
146
    /**
147 3
     * Set the notification icon url.
148
     *
149 3
     * @param  string $value
150
     * @return $this
151 3
     */
152
    public function icon($value)
153
    {
154
        $this->icon = $value;
155
156
        return $this;
157
    }
158
159
    /**
160 1
     * Set the notification image url.
161
     *
162 1
     * @param  string $value
163
     * @return $this
164 1
     */
165
    public function image($value)
166
    {
167
        $this->image = $value;
168
169
        return $this;
170
    }
171
172
    /**
173 1
     * Set the notification language.
174
     *
175 1
     * @param  string $value
176
     * @return $this
177 1
     */
178
    public function lang($value)
179
    {
180
        $this->lang = $value;
181
182
        return $this;
183
    }
184 1
185
    /**
186 1
     * @param  bool $value
187
     * @return $this
188 1
     */
189
    public function renotify($value = true)
190
    {
191
        $this->renotify = $value;
192
193
        return $this;
194
    }
195 1
196
    /**
197 1
     * @param  bool $value
198
     * @return $this
199 1
     */
200
    public function requireInteraction($value = true)
201
    {
202
        $this->requireInteraction = $value;
203
204
        return $this;
205
    }
206
207
    /**
208 1
     * Set the notification tag.
209
     *
210 1
     * @param  string $value
211
     * @return $this
212 1
     */
213
    public function tag($value)
214
    {
215
        $this->tag = $value;
216
217
        return $this;
218
    }
219
220
    /**
221 1
     * Set the notification vibration pattern.
222
     *
223 1
     * @param  array $value
224
     * @return $this
225 1
     */
226
    public function vibrate($value)
227
    {
228
        $this->vibrate = $value;
229
230
        return $this;
231
    }
232
233
    /**
234 3
     * Set the notification arbitrary data.
235
     *
236 3
     * @param  mixed $value
237
     * @return $this
238 3
     */
239
    public function data($value)
240
    {
241
        $this->data = $value;
242
243
        return $this;
244
    }
245
246 15
    /**
247
     * Set the notification options.
248 15
     *
249
     * @param  mixed $value
250
     * @return $this
251
     */
252
    public function options($value)
253
    {
254
        $this->options = $value;
255
256
        return $this;
257
    }
258
259
    /**
260
     * Get an array representation of the message.
261
     *
262
     * @return array
263
     */
264
    public function toArray()
265
    {
266
        return array_filter(get_object_vars($this));
267
    }
268
}
269