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
Pull Request — master (#76)
by
unknown
10:30
created

VerifySlackRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Spatie\SlashCommand\Middleware;
4
5
use Closure;
6
use Spatie\SlashCommand\SlackRequestSignature;
7
8
class VerifySlackRequest
9
{
10
    /** @var SlackRequestSignature */
11
    private $slackRequestSignature;
12
13
    public function __construct(SlackRequestSignature $slackRequestSignature)
14
    {
15
        $this->slackRequestSignature = $slackRequestSignature;
16
    }
17
18
    /**
19
     * @param \Illuminate\Http\Request $request
20
     * @param \Closure $next
21
     *
22
     * @return mixed
23
     */
24
    public function handle($request, Closure $next)
25
    {
26
        $signature = $this->slackRequestSignature->create($request);
27
28
        if (!$this->isEqualsSignature($signature, $request->header('X-Slack-Signature'))) {
0 ignored issues
show
Bug introduced by
It seems like $request->header('X-Slack-Signature') targeting Illuminate\Http\Concerns...actsWithInput::header() can also be of type array or null; however, Spatie\SlashCommand\Midd...st::isEqualsSignature() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
29
            abort(401, 'The request had an invalid signature.');
30
        }
31
32
        return $next($request);
33
    }
34
35
    private function isEqualsSignature(string $signature, string $slackSignature): bool
36
    {
37
        return $signature === $slackSignature;
38
    }
39
}
40