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 (#53)
by
unknown
15:16
created

WebPushMessage::lang()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
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
     * Set the notification title.
77
     *
78
     * @param  string $value
79
     * @return $this
80
     */
81
    public function title($value)
82
    {
83
        $this->title = $value;
84
85
        return $this;
86
    }
87
88
    /**
89
     * Add a notification action.
90
     *
91
     * @param  string $title
92
     * @param  string $action
93
     * @return $this
94
     */
95
    public function action($title, $action)
96
    {
97
        $this->actions[] = compact('title', 'action');
98
99
        return $this;
100
    }
101
102
    /**
103
     * Set the notification badge.
104
     *
105
     * @param  string $value
106
     * @return $this
107
     */
108
    public function badge($value)
109
    {
110
        $this->badge = $value;
111
112
        return $this;
113
    }
114
115
    /**
116
     * Set the notification body.
117
     *
118
     * @param  string $value
119
     * @return $this
120
     */
121
    public function body($value)
122
    {
123
        $this->body = $value;
124
125
        return $this;
126
    }
127
128
    /**
129
     * Set the notification direction.
130
     *
131
     * @param  string $value
132
     * @return $this
133
     */
134
    public function dir($value)
135
    {
136
        $this->dir = $value;
137
138
        return $this;
139
    }
140
141
    /**
142
     * Set the notification icon url.
143
     *
144
     * @param  string $value
145
     * @return $this
146
     */
147
    public function icon($value)
148
    {
149
        $this->icon = $value;
150
151
        return $this;
152
    }
153
154
    /**
155
     * Set the notification image url.
156
     *
157
     * @param  string $value
158
     * @return $this
159
     */
160
    public function image($value)
161
    {
162
        $this->image = $value;
163
164
        return $this;
165
    }
166
167
    /**
168
     * Set the notification language.
169
     *
170
     * @param  string $value
171
     * @return $this
172
     */
173
    public function lang($value)
174
    {
175
        $this->lang = $value;
176
177
        return $this;
178
    }
179
180
    /**
181
     * @param  bool $value
182
     * @return $this
183
     */
184
    public function renotify($value = true)
185
    {
186
        $this->renotify = $value;
187
188
        return $this;
189
    }
190
191
    /**
192
     * @param  bool $value
193
     * @return $this
194
     */
195
    public function requireInteraction($value = true)
196
    {
197
        $this->requireInteraction = $value;
198
199
        return $this;
200
    }
201
202
    /**
203
     * Set the notification tag.
204
     *
205
     * @param  string $value
206
     * @return $this
207
     */
208
    public function tag($value)
209
    {
210
        $this->tag = $value;
211
212
        return $this;
213
    }
214
215
    /**
216
     * Set the notification vibration pattern.
217
     *
218
     * @param  array $value
219
     * @return $this
220
     */
221
    public function vibrate($value)
222
    {
223
        $this->vibrate = $value;
224
225
        return $this;
226
    }
227
228
    /**
229
     * Set the notification arbitrary data.
230
     *
231
     * @param  mixed $value
232
     * @return $this
233
     */
234
    public function data($value)
235
    {
236
        $this->data = $value;
237
238
        return $this;
239
    }
240
241
    /**
242
     * Get an array representation of the message.
243
     *
244
     * @return array
245
     */
246
    public function toArray()
247
    {
248
        return collect([
249
            'title',
250
            'actions',
251
            'badge',
252
            'body',
253
            'dir',
254
            'icon',
255
            'image',
256
            'lang',
257
            'renotify',
258
            'requireInteraction',
259
            'tag',
260
            'vibrate',
261
            'data',
262
        ])
263
        ->map(function ($option) {
264
            return [$option => $this->{$option}];
265
        })
266
        ->reject(function ($value) {
267
            return is_null($value);
268
        })
269
        ->toArray();
270
    }
271
}
272