Test Failed
Push — feature/improve ( 4f0633 )
by Yo
02:21
created

BehatKernelEventDispatcher::beforeBoot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 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 requirement in the AppKernel mock
13
 *
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)
0 ignored issues
show
Compatibility introduced by
$kernel of type object<Symfony\Component...Kernel\KernelInterface> is not a sub-type of object<Symfony\Component\HttpKernel\Kernel>. It seems like you assume a concrete implementation of the interface Symfony\Component\HttpKernel\KernelInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
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)
0 ignored issues
show
Compatibility introduced by
$kernel of type object<Symfony\Component...Kernel\KernelInterface> is not a sub-type of object<Symfony\Component\HttpKernel\Kernel>. It seems like you assume a concrete implementation of the interface Symfony\Component\HttpKernel\KernelInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
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)
0 ignored issues
show
Compatibility introduced by
$kernel of type object<Symfony\Component...Kernel\KernelInterface> is not a sub-type of object<Symfony\Component\HttpKernel\Kernel>. It seems like you assume a concrete implementation of the interface Symfony\Component\HttpKernel\KernelInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
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)
0 ignored issues
show
Compatibility introduced by
$kernel of type object<Symfony\Component...Kernel\KernelInterface> is not a sub-type of object<Symfony\Component\HttpKernel\Kernel>. It seems like you assume a concrete implementation of the interface Symfony\Component\HttpKernel\KernelInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
70
        );
71
    }
72
}
73