Failed Conditions
Pull Request — master (#17)
by Yo
04:43 queued 02:21
created

BehatKernelEventDispatcher::afterBoot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 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 4
    public function __construct(EventDispatcherInterface $behatEventDispatcher)
25
    {
26 4
        $this->behatEventDispatcher = $behatEventDispatcher;
27 4
    }
28
29
    /**
30
     * @param KernelInterface $kernel
31
     */
32 1
    public function beforeBoot(KernelInterface $kernel)
33
    {
34 1
        $this->behatEventDispatcher->dispatch(
35 1
            Events::BEFORE_KERNEL_BOOT,
36 1
            new KernelEvent($kernel)
37 1
        );
38 1
    }
39
40
    /**
41
     * @param KernelInterface $kernel
42
     */
43 1
    public function afterBoot(KernelInterface $kernel)
44
    {
45 1
        $this->behatEventDispatcher->dispatch(
46 1
            Events::AFTER_KERNEL_BOOT,
47 1
            new KernelEvent($kernel)
48 1
        );
49 1
    }
50
51
    /**
52
     * @param KernelInterface $kernel
53
     */
54 1
    public function beforeShutdown(KernelInterface $kernel)
55
    {
56 1
        $this->behatEventDispatcher->dispatch(
57 1
            Events::BEFORE_KERNEL_SHUTDOWN,
58 1
            new KernelEvent($kernel)
59 1
        );
60 1
    }
61
62
    /**
63
     * @param KernelInterface $kernel
64
     */
65 1
    public function afterShutdown(KernelInterface $kernel)
66
    {
67 1
        $this->behatEventDispatcher->dispatch(
68 1
            Events::AFTER_KERNEL_SHUTDOWN,
69 1
            new KernelEvent($kernel)
70 1
        );
71 1
    }
72
}
73