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.

BaseHandler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
canHandle() 0 1 ?
handle() 0 1 ?
A __construct() 0 4 1
A respondToSlack() 0 4 1
A dispatch() 0 6 1
A abort() 0 4 1
A getRequest() 0 4 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\SlackSlashCommandException;
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 SlackSlashCommandException($response);
40
    }
41
42
    public function getRequest(): Request
43
    {
44
        return $this->request;
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