Completed
Push — master ( 37a280...0c4ce1 )
by Yo
02:09
created

BehatKernelEventDispatcher   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

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\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 4
    public function __construct(EventDispatcherInterface $behatEventDispatcher)
24
    {
25 4
        $this->behatEventDispatcher = $behatEventDispatcher;
26 4
    }
27
28
    /**
29
     * @param KernelInterface $kernel
30
     */
31 1
    public function beforeBoot(KernelInterface $kernel)
32
    {
33 1
        $this->behatEventDispatcher->dispatch(
34 1
            Events::BEFORE_KERNEL_BOOT,
35 1
            new KernelEvent($kernel)
36 1
        );
37 1
    }
38
39
    /**
40
     * @param KernelInterface $kernel
41
     */
42 1
    public function afterBoot(KernelInterface $kernel)
43
    {
44 1
        $this->behatEventDispatcher->dispatch(
45 1
            Events::AFTER_KERNEL_BOOT,
46 1
            new KernelEvent($kernel)
47 1
        );
48 1
    }
49
50
    /**
51
     * @param KernelInterface $kernel
52
     */
53 1
    public function beforeShutdown(KernelInterface $kernel)
54
    {
55 1
        $this->behatEventDispatcher->dispatch(
56 1
            Events::BEFORE_KERNEL_SHUTDOWN,
57 1
            new KernelEvent($kernel)
58 1
        );
59 1
    }
60
61
    /**
62
     * @param KernelInterface $kernel
63
     */
64 1
    public function afterShutdown(KernelInterface $kernel)
65
    {
66 1
        $this->behatEventDispatcher->dispatch(
67 1
            Events::AFTER_KERNEL_SHUTDOWN,
68 1
            new KernelEvent($kernel)
69 1
        );
70 1
    }
71
}
72