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 ( 08ea9d...7729c5 )
by Freek
02:30
created

BaseHandler::abort()   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\Handlers;
4
5
use Illuminate\Contracts\Bus\Dispatcher;
6
use Illuminate\Foundation\Bus\DispatchesJobs;
7
use Spatie\SlashCommand\Exceptions\SlashException;
8
use Spatie\SlashCommand\HandlesSlashCommand;
9
use Spatie\SlashCommand\Jobs\SlashCommandResponseJob;
10
use Spatie\SlashCommand\Request;
11
use Spatie\SlashCommand\Response;
12
13
abstract class BaseHandler implements HandlesSlashCommand
14
{
15
    use DispatchesJobs;
16
17
    /** @var \Spatie\SlashCommand\Request */
18
    protected $request;
19
20
    public function __construct(Request $request)
21
    {
22
        $this->request = $request;
23
    }
24
25
    public function respondToSlack(string $text): Response
26
    {
27
        return Response::create($this->request)->withText($text);
28
    }
29
30
    protected function dispatch(SlashCommandResponseJob $job)
31
    {
32
        $job->setRequest($this->request);
33
34
        return app(Dispatcher::class)->dispatch($job);
35
    }
36
37
    protected function abort($response)
38
    {
39
        throw new SlashException($response);
40
    }
41
42
    public function getRequest(): Request
43
    {
44
        return $this->getRequest();
45
    }
46
47
    /**
48
     * If this function returns true, the handle method will get called.
49
     *
50
     * @param \Spatie\SlashCommand\Request $request
51
     *
52
     * @return bool
53
     */
54
    abstract public function canHandle(Request $request): bool;
55
56
    /**
57
     * Handle the given request. Remember that Slack expects a response
58
     * within three seconds after the slash command was issued. If
59
     * there is more time needed, dispatch a job.
60
     *
61
     * @param \Spatie\SlashCommand\Request $request
62
     *
63
     * @return \Spatie\SlashCommand\Response
64
     */
65
    abstract public function handle(Request $request): Response;
66
}
67