WebhookRetryListener::getSubscribedEvents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
}