WebhookRetryListener   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 6 1
A handle() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Webhook\Bundle\EventListener;
6
7
8
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
9
use Webhook\Bundle\Event\WebhookEvent;
10
use Webhook\Bundle\WebhookEvents;
11
use Webhook\Domain\Infrastructure\HandlerInterface;
12
13
/**
14
 * Class WebhookRetryListener
15
 *
16
 * @package Webhook\Bundle\EventListener
17
 */
18
final class WebhookRetryListener implements EventSubscriberInterface
19
{
20
    /** @var  HandlerInterface */
21
    private $retryHandler;
22
23
    /**
24
     * WebhookRetryListener constructor.
25
     *
26
     * @param HandlerInterface $retryHandler
27
     */
28
    public function __construct(HandlerInterface $retryHandler)
29
    {
30
        $this->retryHandler = $retryHandler;
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public static function getSubscribedEvents(): array
37
    {
38
        return [
39
            WebhookEvents::WEBHOOK_RETRY => 'handle',
40
        ];
41
    }
42
43
    /**
44
     * @param WebhookEvent $event
45
     */
46
    public function handle(WebhookEvent $event)
47
    {
48
        $this->retryHandler->handle($event->getWebhook());
49
    }
50
}