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
Push — master ( 03c23b...59992b )
by Freek
02:08
created

Request::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Spatie\SlashCommand;
4
5
use Illuminate\Http\Request as IlluminateRequest;
6
7
class Request
8
{
9
    /** @var string */
10
    public $token;
11
12
    /** @var string */
13
    public $teamId;
14
15
    /** @var string */
16
    public $teamDomain;
17
18
    /** @var string */
19
    public $channelName;
20
21
    /** @var string */
22
    public $userId;
23
24
    /** @var string */
25
    public $userName;
26
27
    /** @var string */
28
    public $command;
29
30
    /** @var string */
31
    public $text;
32
33
    /** @var string */
34
    public $responseUrl;
35
36
    public static function createFromIlluminateRequest(IlluminateRequest $illuminateRequest): Request
37
    {
38
        return collect([
39
            'token',
40
            'teamId',
41
            'teamDomain',
42
            'channelId',
43
            'channelName',
44
            'userId',
45
            'userName',
46
            'command',
47
            'text',
48
            'responseUrl',
49
        ])->reduce(function (Request $request, string $propertyName) use ($illuminateRequest) {
50
51
52
            $request->$propertyName = $illuminateRequest->get(snake_case($propertyName));
53
54
            if ($propertyName == 'command') {
55
56
                //remove slash
57
                $request->command = substr($request->command, 1);
58
            }
59
            return $request;
60
        }, new static());
61
    }
62
63
    public function get(string $propertyName): string
64
    {
65
        return $this->$propertyName ?? '';
66
    }
67
68
    public function all(): array
69
    {
70
        return get_object_vars($this);
71
    }
72
}
73