EnvAwareInitializer::initializeContext()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * This file is part of the Behat Environment Extension.
4
 * (c) Erik Wohllebe <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Wohlie\Behat\Environment\Context\Initializer;
11
12
use Behat\Behat\Context\Context;
13
use Behat\Behat\Context\Initializer\ContextInitializer;
14
use Wohlie\Behat\Environment\Context\EnvAwareContext;
15
use Wohlie\Behat\Environment\Env;
16
17
class EnvAwareInitializer implements ContextInitializer
18
{
19
    /**
20
     * Holds the environment.
21
     *
22
     * @var Env
23
     */
24
    protected $env;
25
26
    /**
27
     * EnvAwareInitializer constructor.
28
     *
29
     * @param Env $env
30
     */
31
    public function __construct(Env $env)
32
    {
33
        $this->env = $env;
34
    }
35
36
    /**
37
     * Initializes provided context.
38
     *
39
     * @param Context $context
40
     */
41
    public function initializeContext(Context $context)
42
    {
43
        if (!$context instanceof EnvAwareContext) {
44
            return;
45
        }
46
47
        $context->setEnv($this->env);
48
    }
49
}