Completed
Push — develop ( 7b4528...3818c9 )
by Baptiste
07:33
created

CloseListener::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQPBundle\EventListener;
5
6
use Innmind\AMQP\Client;
7
use Symfony\Component\{
8
    EventDispatcher\EventSubscriberInterface,
9
    HttpKernel\KernelEvents,
10
    Console\ConsoleEvents
11
};
12
13
final class CloseListener implements EventSubscriberInterface
14
{
15
    private $client;
16
17
    public function __construct(Client $client)
18
    {
19
        $this->client = $client;
20
    }
21
22
    public static function getSubscribedEvents(): array
23
    {
24
        return [
25
            KernelEvents::TERMINATE => 'close',
26
            ConsoleEvents::TERMINATE => 'close',
27
        ];
28
    }
29
30
    public function close(): void
31
    {
32
        $this->client->close();
33
    }
34
}
35