Completed
Push — master ( cf6f30...545cd2 )
by Yo
02:19
created

RebootKernelSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 36
rs 10
c 1
b 0
f 0
ccs 12
cts 12
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getSubscribedEvents() 0 7 1
A reset() 0 6 1
1
<?php
2
namespace Yoanm\Behat3SymfonyExtension\Subscriber;
3
4
use Behat\Behat\EventDispatcher\Event\ExampleTested;
5
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
6
use Psr\Log\LoggerInterface;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
use Yoanm\Behat3SymfonyExtension\Client\Client;
9
10
/**
11
 * Class RebootKernelSubscriber
12
 */
13
class RebootKernelSubscriber implements EventSubscriberInterface
14
{
15
    /** @var Client */
16
    private $client;
17
    /** @var LoggerInterface */
18
    private $logger;
19
20
    /**
21
     * @param Client $client
22
     */
23 2
    public function __construct(
24
        Client $client,
25
        LoggerInterface $logger
26
    ) {
27 2
        $this->client = $client;
28 2
        $this->logger = $logger;
29 2
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    public static function getSubscribedEvents()
35
    {
36
        return [
37 1
            ScenarioTested::BEFORE => 'reset',
38 1
            ExampleTested::BEFORE => 'reset',
39 1
        ];
40
    }
41
42 1
    public function reset()
43
    {
44
        // Resetting the client will also reboot the kernel
45 1
        $this->logger->debug('Resetting mink driver client');
46 1
        $this->client->resetClient();
47 1
    }
48
}
49