Completed
Push — master ( 4c7365...be3bdc )
by Vladimir
02:21
created

Controller   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
ccs 0
cts 9
cp 0
rs 10
wmc 4
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 4 1
A webhook() 0 16 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Foundation;
6
7
use FondBot\Contracts\Event;
8
use Illuminate\Contracts\Events\Dispatcher;
9
use FondBot\Drivers\Extensions\WebhookVerification;
10
11
class Controller
12
{
13
    public function index()
14
    {
15
        return 'FondBot v'.Kernel::VERSION;
16
    }
17
18
    public function webhook(Kernel $kernel, Dispatcher $events): Event
19
    {
20
        $driver = $kernel->getDriver();
21
22
        // If driver supports webhook verification
23
        // We need to check if current request belongs to verification process
24
        if ($driver instanceof WebhookVerification && $driver->isVerificationRequest()) {
25
            return $driver->verifyWebhook();
26
        }
27
28
        $event = $kernel->getEvent();
29
30
        $events->dispatch($event);
31
32
        return $event;
33
    }
34
}
35