Failed Conditions
Pull Request — release/0.2.0 (#35)
by Yo
05:02
created

BehatKernelEventDispatcher::afterShutdown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
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\KernelInterface;
6
use Yoanm\Behat3SymfonyExtension\Event\Events;
7
use Yoanm\Behat3SymfonyExtension\Event\KernelEvent;
8
9
/**
10
 * Will dispatch events related to symfony app kernel
11
 * It's just a wrapper to have the minimum of requirements in the AppKernel mock
12
 * and the maximum of code coverage for this extension
13
 * @see Yoanm\Behat3SymfonyExtension\Factory\KernelFactory::load()
14
 */
15
class BehatKernelEventDispatcher
16
{
17
    /** @var EventDispatcherInterface */
18
    private $behatEventDispatcher;
19
20
    /**
21
     * @param EventDispatcherInterface $behatEventDispatcher
22
     */
23
    public function __construct(EventDispatcherInterface $behatEventDispatcher)
24
    {
25
        $this->behatEventDispatcher = $behatEventDispatcher;
26
    }
27
28
    /**
29
     * @param KernelInterface $kernel
30
     */
31
    public function beforeBoot(KernelInterface $kernel)
32
    {
33
        $this->behatEventDispatcher->dispatch(
34
            Events::BEFORE_KERNEL_BOOT,
35
            new KernelEvent($kernel)
36
        );
37
    }
38
39
    /**
40
     * @param KernelInterface $kernel
41
     */
42
    public function afterBoot(KernelInterface $kernel)
43
    {
44
        $this->behatEventDispatcher->dispatch(
45
            Events::AFTER_KERNEL_BOOT,
46
            new KernelEvent($kernel)
47
        );
48
    }
49
50
    /**
51
     * @param KernelInterface $kernel
52
     */
53
    public function beforeShutdown(KernelInterface $kernel)
54
    {
55
        $this->behatEventDispatcher->dispatch(
56
            Events::BEFORE_KERNEL_SHUTDOWN,
57
            new KernelEvent($kernel)
58
        );
59
    }
60
61
    /**
62
     * @param KernelInterface $kernel
63
     */
64
    public function afterShutdown(KernelInterface $kernel)
65
    {
66
        $this->behatEventDispatcher->dispatch(
67
            Events::AFTER_KERNEL_SHUTDOWN,
68
            new KernelEvent($kernel)
69
        );
70
    }
71
}
72