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

KernelAwareInitializer::initializeContext()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
namespace Yoanm\Behat3SymfonyExtension\Context\Initializer;
3
4
use Behat\Behat\Context\Context;
5
use Behat\Behat\Context\Initializer\ContextInitializer;
6
use Symfony\Component\HttpKernel\KernelInterface;
7
use Yoanm\Behat3SymfonyExtension\Context\KernelAwareInterface;
8
9
/**
10
 * Class KernelAwareInitializer
11
 */
12
class KernelAwareInitializer implements ContextInitializer
13
{
14
    /** @var KernelInterface */
15
    private $kernel;
16
17
    /**
18
     * @param KernelInterface $kernel
19
     */
20
    public function __construct(KernelInterface $kernel)
21
    {
22
        $this->kernel = $kernel;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function initializeContext(Context $context)
29
    {
30
        if (!$context instanceof KernelAwareInterface) {
31
            return;
32
        }
33
34
        $context->setKernel($this->kernel);
35
    }
36
}
37