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 ( b62982...d1158c )
by Freek
02:01
created

SlashCommandResponse::setText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Spatie\SlashCommand;
4
5
use Illuminate\Http\Response;
6
7
class SlashCommandResponse extends Response
8
{
9
    /** @var SlashCommandRequest */
10
    protected $request;
11
12
    /** @var string */
13
    protected $text;
14
15
    /** @var string */
16
    protected $responseType = 'ephemeral';
17
18
    /** @var string */
19
    protected $attachments = '';
20
21
    public static function createForRequest(SlashCommandRequest $request)
22
    {
23
        return (new static())
24
            ->setRequest($request)
25
            ->displayResponseOnlyToUserWhoTypedCommand();
26
    }
27
28
    public function setRequest(SlashCommandRequest $request)
29
    {
30
        $this->responseType = $request;
0 ignored issues
show
Documentation Bug introduced by
It seems like $request of type object<Spatie\SlashCommand\SlashCommandRequest> is incompatible with the declared type string of property $responseType.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
31
32
        return $this;
33
    }
34
35
    public function setText(string $text)
36
    {
37
        $this->text = $text;
38
39
        return $this;
40
    }
41
42
    public function displayResponseOnlyToUserWhoTypedCommand()
43
    {
44
        $this->responseType = 'ephemeral';
45
46
        return $this;
47
    }
48
49
    public function displayResponseToEveryoneOnChannel()
50
    {
51
        $this->type = 'in_channel';
0 ignored issues
show
Bug introduced by
The property type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
52
53
        return $this;
54
    }
55
56
    /**
57
     * Prepares the payload to be sent to the reponse.
58
     */
59
    public function __toString()
60
    {
61
        $payload = [
62
            'text' => $this->getText(),
0 ignored issues
show
Bug introduced by
The method getText() does not seem to exist on object<Spatie\SlashCommand\SlashCommandResponse>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
            'link_names' => true,
64
            'unfurl_links' => true,
65
            'unfurl_media' => true,
66
            'mrkdwn' => true,
67
            'response_type' => $this->responseType,
68
        ];
69
70
        $payload['attachments'] = $this->attachments;
71
72
        $this->setContent($payload);
73
74
        return parent::__toString();
75
    }
76
}
77