Failed Conditions
Pull Request — master (#17)
by Yo
02:16
created

BehatKernelEventDispatcher   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 57
ccs 0
cts 32
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A beforeBoot() 0 7 1
A afterBoot() 0 7 1
A beforeShutdown() 0 7 1
A afterShutdown() 0 7 1
1
<?php
2
namespace Yoanm\Behat3SymfonyExtension\Dispatcher;
3
4
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
5
use Symfony\Component\HttpKernel\Kernel;
6
use Symfony\Component\HttpKernel\KernelInterface;
7
use Yoanm\Behat3SymfonyExtension\Event\Events;
8
use Yoanm\Behat3SymfonyExtension\Event\KernelEvent;
9
10
/**
11
 * Will dispatch events related to symfony app kernel
12
 * It's just a wrapper to have the minimum of requirements in the AppKernel mock
13
 * and the maximum of code coverage for this extension
14
 * @see Yoanm\Behat3SymfonyExtension\Factory\KernelFactory::load()
15
 */
16
class BehatKernelEventDispatcher
17
{
18
    /** @var EventDispatcherInterface */
19
    private $behatEventDispatcher;
20
21
    /**
22
     * @param EventDispatcherInterface $behatEventDispatcher
23
     */
24
    public function __construct(EventDispatcherInterface $behatEventDispatcher)
25
    {
26
        $this->behatEventDispatcher = $behatEventDispatcher;
27
    }
28
29
    /**
30
     * @param KernelInterface $kernel
31
     */
32
    public function beforeBoot(KernelInterface $kernel)
33
    {
34
        $this->behatEventDispatcher->dispatch(
35
            Events::BEFORE_KERNEL_BOOT,
36
            new KernelEvent($kernel)
37
        );
38
    }
39
40
    /**
41
     * @param KernelInterface $kernel
42
     */
43
    public function afterBoot(KernelInterface $kernel)
44
    {
45
        $this->behatEventDispatcher->dispatch(
46
            Events::AFTER_KERNEL_BOOT,
47
            new KernelEvent($kernel)
48
        );
49
    }
50
51
    /**
52
     * @param KernelInterface $kernel
53
     */
54
    public function beforeShutdown(KernelInterface $kernel)
55
    {
56
        $this->behatEventDispatcher->dispatch(
57
            Events::BEFORE_KERNEL_SHUTDOWN,
58
            new KernelEvent($kernel)
59
        );
60
    }
61
62
    /**
63
     * @param KernelInterface $kernel
64
     */
65
    public function afterShutdown(KernelInterface $kernel)
66
    {
67
        $this->behatEventDispatcher->dispatch(
68
            Events::AFTER_KERNEL_SHUTDOWN,
69
            new KernelEvent($kernel)
70
        );
71
    }
72
}
73