Completed
Pull Request — master (#4)
by Morten Poul
11:21
created

WebhookFailed::missingTopic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Signifly\Shopify\Exceptions;
4
5
use Exception;
6
7
class WebhookFailed extends Exception
8
{
9
    public static function missingSignature()
10
    {
11
        return new static('The request did not contain a header named `X-Shopify-Hmac-Sha256`.');
12
    }
13
14
    public static function invalidSignature(string $signature)
15
    {
16
        return new static("The signature `{$signature}` found in the header named `X-Shopify-Hmac-Sha256` is invalid.");
17
    }
18
19
    public static function missingSigningSecret()
20
    {
21
        return new static('The webhook signing secret is not set.');
22
    }
23
24
    public static function missingTopic()
25
    {
26
        return new static('The webhook call did not contain a topic. Valid webhook calls should always contain a topic.');
27
    }
28
29
    /**
30
     * Render the exception into an HTTP response.
31
     *
32
     * NOTE: https://laravel.com/docs/5.5/errors#renderable-exceptions
33
     *
34
     * @param  \Illuminate\Http\Request $request
35
     * @return \Illuminate\Http\Response
36
     */
37
    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

37
    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...
38
    {
39
        return response(['error' => $this->getMessage()], 400);
40
    }
41
}
42