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

CloseListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 7 1
A close() 0 4 1
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