Completed
Push — master ( 673226...2f9fa2 )
by Freek
01:35
created

WebhookFailed::missingType()   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\StripeWebhooks\Exceptions;
4
5
use Exception;
6
use Spatie\StripeWebhooks\StripeWebhookCall;
7
8
class WebhookFailed extends Exception
9
{
10
    public static function signatureMissing()
11
    {
12
        return new static('The request did not contain a header named `Stripe-Signature`');
13
    }
14
15
    public static function invalidSignature($signature)
16
    {
17
        return new static("The signature `{$signature}` found in the header named `Stripe-Signature` is invalid. Make sure that the `services.stripe.webhook_signing_secret` config key is set to the value you found on the Stripe dashboard. If you are caching your config try running `php artisan clear:cache` to resolve the problem.");
18
    }
19
20
    public static function signingSecretNotSet()
21
    {
22
        return new static('The Stripe webhook signing secret is not set. Make sure that the `services.stripe.webhook_signing_secret` config key is set to the value you found on the Stripe dashboard.');
23
    }
24
25
    public static function jobClassDoesNotExist(string $jobClass, StripeWebhookCall $webhookCall)
26
    {
27
        return new static("Could not process webhook id `{$webhookCall->id}` of type `{$webhookCall->type} because the configured jobclass `$jobClass` does not exist");
28
    }
29
30
    public static function missingType(StripeWebhookCall $webhookCall)
31
    {
32
        return new static("Webhook call id `{$webhookCall->id}` did not contain a type. Valid Stripe webhook calls should always contain a type.");
33
    }
34
35
    public function render($request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        return response(['error' => $this->getMessage()], 400);
0 ignored issues
show
Documentation introduced by
array('error' => $this->getMessage()) is of type array<string,string,{"error":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
38
    }
39
}
40