WebhookException::invalidSignature()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Integrations\Exceptions;
4
5
use Exception;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Integrations\Exceptions\Exception.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
6
use Illuminate\Http\Request;
7
8
class WebhookException extends Exception
9
{
10
    public static function missingSignature()
11
    {
12
        return new static('The request did not contain a header named `Integrations-Signature`.');
13
    }
14
15
    public static function invalidSignature($signature)
16
    {
17
        return new static("The signature `{$signature}` found in the header named `Integrations-Signature` is invalid. Make sure that the use has configured the webhook field to the value you on the Socrates dashboard.");
18
    }
19
20
    public static function signingSecretNotSet()
21
    {
22
        return new static('The Integrations webhook signing secret is not set. Make sure that the user has configured the webhook field to the value on the Socrates dashboard.');
23
    }
24
25
    public static function missingType()
26
    {
27
        return new static('The webhook call did not contain a type. Valid Integrations webhook calls should always contain a type.');
28
    }
29
30
    public static function unrecognizedType($type)
31
    {
32
        return new static("The type {$type} is not currently supported.");
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);
38
    }
39
}
40