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.

Issues (41)

src/Http/Controllers/WebhookController.php (7 issues)

1
<?php
2
3
namespace Multicoin\Api\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Routing\Controller;
7
use Multicoin\Api\Exceptions\WebhookFailed;
8
use Multicoin\Api\Http\Middlewares\VerifySignature;
9
use Multicoin\Api\WebhookCall;
10
11
class WebhookController extends Controller
12
{
13
    public function __construct()
14
    {
15
        $this->middleware(VerifySignature::class);
16
    }
17
18
    public function __invoke(Request $request)
19
    {
20
        $eventPayload = $this->getJsonPayloadFromRequest($request);
21
        if (! isset($eventPayload['type'])) {
22
            throw WebhookFailed::missingType($request);
23
        }
24
        $type = $eventPayload['type'];
25
        $WebhookCall = new WebhookCall($eventPayload);
0 ignored issues
show
Variable "WebhookCall" is not in valid camel caps format
Loading history...
26
        event("multicoin-webhooks::{$type}", $WebhookCall);
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $type instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Variable "WebhookCall" is not in valid camel caps format
Loading history...
27
        $jobClass = $this->determineJobClass($type);
28
        if ('' === $jobClass) {
29
            return;
30
        }
31
        if (! class_exists($jobClass)) {
32
            throw WebhookFailed::jobClassDoesNotExist($jobClass, $WebhookCall);
0 ignored issues
show
Variable "WebhookCall" is not in valid camel caps format
Loading history...
The method jobClassDoesNotExist() does not exist on Multicoin\Api\Exceptions\WebhookFailed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
            throw WebhookFailed::/** @scrutinizer ignore-call */ jobClassDoesNotExist($jobClass, $WebhookCall);

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...
33
        }
34
        dispatch(new $jobClass($WebhookCall));
0 ignored issues
show
Variable "WebhookCall" is not in valid camel caps format
Loading history...
35
    }
36
37
    protected function determineJobClass(string $type)
38
    {
39
        return config("multicoin.jobs.{$type}", '');
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $type instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
40
    }
41
42
    private function getJsonPayloadFromRequest($request)
43
    {
44
        return (array) json_decode($request->getContent(), true);
45
    }
46
}
47