1 | <?php |
||||||
2 | /** |
||||||
3 | * Created by PhpStorm. |
||||||
4 | * User: eudaldarranztresserra |
||||||
5 | * Date: 2019-03-01 |
||||||
6 | * Time: 13:08 |
||||||
7 | */ |
||||||
8 | |||||||
9 | namespace Nestednet\Gocardless; |
||||||
10 | |||||||
11 | use Exception; |
||||||
12 | use Illuminate\Database\Eloquent\Model; |
||||||
0 ignored issues
–
show
|
|||||||
13 | use Nestednet\Gocardless\Exceptions\WebhookFailed; |
||||||
14 | |||||||
15 | class GocardlessWebhookCall extends Model |
||||||
16 | { |
||||||
17 | public $guarded = []; |
||||||
18 | |||||||
19 | protected $casts = [ |
||||||
20 | 'payload' => 'array', |
||||||
21 | 'exception' => 'array', |
||||||
22 | ]; |
||||||
23 | |||||||
24 | public function process() |
||||||
25 | { |
||||||
26 | $this->clearException(); |
||||||
27 | |||||||
28 | if ($this->resource_type === '') { |
||||||
29 | throw WebhookFailed::missingResource($this); |
||||||
30 | } |
||||||
31 | |||||||
32 | if ($this->action === '') { |
||||||
33 | throw WebhookFailed::missingAction($this); |
||||||
34 | } |
||||||
35 | |||||||
36 | event("gocardless-webhooks::{$this->resource_type}_{$this->action}", $this); |
||||||
0 ignored issues
–
show
The function
event 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
![]() |
|||||||
37 | |||||||
38 | $jobClass = $this->determineJobClass($this->resource_type, $this->action); |
||||||
39 | |||||||
40 | if ($jobClass === "") { |
||||||
41 | return; |
||||||
42 | } |
||||||
43 | |||||||
44 | if (! class_exists($jobClass)) { |
||||||
45 | throw WebhookFailed::jobClassDoesNotExist($jobClass, $this); |
||||||
46 | } |
||||||
47 | |||||||
48 | dispatch(new $jobClass($this)); |
||||||
0 ignored issues
–
show
The function
dispatch 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
![]() |
|||||||
49 | } |
||||||
50 | |||||||
51 | public function saveException(Exception $exception) |
||||||
52 | { |
||||||
53 | $this->exception = [ |
||||||
0 ignored issues
–
show
|
|||||||
54 | 'code' => $exception->getCode(), |
||||||
55 | 'message' => $exception->getMessage(), |
||||||
56 | 'trace' => $exception->getTraceAsString(), |
||||||
57 | ]; |
||||||
58 | |||||||
59 | $this->save(); |
||||||
60 | |||||||
61 | return $this; |
||||||
62 | } |
||||||
63 | |||||||
64 | protected function determineJobClass(string $resourceType, string $action) : string |
||||||
65 | { |
||||||
66 | $formattedResourceType = str_replace('.', '_', $resourceType); |
||||||
67 | $formattedAction = str_replace('.', '_', $action); |
||||||
68 | |||||||
69 | $jobClassKey = "{$formattedResourceType}_{$formattedAction}"; |
||||||
70 | |||||||
71 | return config("gocardless.webhooks.jobs.{$jobClassKey}", ""); |
||||||
0 ignored issues
–
show
The function
config 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
![]() |
|||||||
72 | } |
||||||
73 | |||||||
74 | protected function clearException() |
||||||
75 | { |
||||||
76 | $this->exception = null; |
||||||
0 ignored issues
–
show
|
|||||||
77 | |||||||
78 | $this->save(); |
||||||
79 | |||||||
80 | return $this; |
||||||
81 | } |
||||||
82 | |||||||
83 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths