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.

WebPushMessage::action()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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