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

BehatKernelEventDispatcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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