Completed
Push — master ( 06f997...84d5d5 )
by Vladimir
03:43
created

WebhookController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A store() 0 16 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Foundation\Http\Controllers;
6
7
use Illuminate\Http\Request;
8
use FondBot\Foundation\Kernel;
9
use Illuminate\Events\Dispatcher;
10
use Illuminate\Routing\Controller;
11
use FondBot\Contracts\Channels\WebhookVerification;
12
13
class WebhookController extends Controller
14
{
15
    public function store(Kernel $kernel, Dispatcher $events, Request $request)
16
    {
17
        $driver = $kernel->getChannel()->getDriver();
18
19
        // If driver supports webhook verification
20
        // We need to check if current request belongs to verification process
21
        if ($driver instanceof WebhookVerification && $driver->isVerificationRequest($request)) {
22
            return $driver->verifyWebhook($request);
23
        }
24
25
        // Resolve event from driver and dispatch it
26
        $events->dispatch(
27
            $event = $driver->createEvent($request)
28
        );
29
30
        return $driver->createResponse($request, $event);
0 ignored issues
show
Bug introduced by
The method createResponse() does not exist on FondBot\Channels\Driver. ( Ignorable by Annotation )

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

30
        return $driver->/** @scrutinizer ignore-call */ createResponse($request, $event);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
    }
32
}
33