Passed
Push — master ( 8c743d...154964 )
by Eudald
10:11
created

WebhookFailed   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A missingSignature() 0 3 1
A render() 0 3 1
A jobClassDoesNotExist() 0 3 1
A noSecretKeyProvided() 0 3 1
A invalidSignature() 0 3 1
A missingResource() 0 3 1
A missingAction() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: eudaldarranztresserra
5
 * Date: 2019-03-01
6
 * Time: 13:07
7
 */
8
9
namespace Nestednet\Gocardless\Exceptions;
10
11
use Exception;
12
use Nestednet\Gocardless\GocardlessWebhookCall;
13
14
class WebhookFailed extends Exception
15
{
16
    public static function missingSignature()
17
    {
18
        return new static('The request did not contain a Signature header - `Webhook-Signature`.');
19
    }
20
21
    public static function invalidSignature($signature)
22
    {
23
        return new static("The signature: {$signature} found in the header is invalid.");
24
    }
25
26
    public static function noSecretKeyProvided()
27
    {
28
        return new static('The webhook secret key is not set.');
29
    }
30
31
    public static function jobClassDoesNotExist(string $jobClass, GocardlessWebhookCall $webhookCall)
32
    {
33
        return new static("Could not process webhook id `{$webhookCall->id}` of type `{$webhookCall->type} because the configured jobclass `$jobClass` does not exist.");
34
    }
35
36
    public static function missingResource(GocardlessWebhookCall $webhookCall)
37
    {
38
        return new static("Webhook call id `{$webhookCall->id}` did not contain a resource type. Valid Gocardless webhook calls should always contain a resource type.");
39
    }
40
41
    public static function missingAction(GocardlessWebhookCall $webhookCall)
42
    {
43
        return new static("Webhook call id `{$webhookCall->id}` did not contain an action. Valid Gocardless webhook calls should always contain an action.");
44
    }
45
46
    public function render($request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

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

46
    public function render(/** @scrutinizer ignore-unused */ $request)

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

Loading history...
47
    {
48
        return response(['error' => $this->getMessage()], 400);
0 ignored issues
show
Bug introduced by
The function response was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

48
        return /** @scrutinizer ignore-call */ response(['error' => $this->getMessage()], 400);
Loading history...
49
    }
50
51
}