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.

Request   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 68
rs 10
c 0
b 0
f 0

3 Methods

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