JsonHolderAwareInitializer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace JsonSpec\Behat\Context\Initializer;
4
5
use Behat\Behat\Context\Context;
6
use Behat\Behat\Context\Initializer\ContextInitializer;
7
use JsonSpec\Behat\Context\JsonConsumerAware;
8
use JsonSpec\Behat\Consumer\JsonConsumer;
9
use JsonSpec\Behat\Context\JsonHolderAware;
10
use JsonSpec\Behat\JsonProvider\JsonHolder;
11
12
/**
13
 * Class JsonHolderAwareInitializer
14
 * @package JsonSpec\Behat\Context\Initializer
15
 */
16
class JsonHolderAwareInitializer implements ContextInitializer
17
{
18
19
    /**
20
     * @var JsonHolder
21
     */
22
    private $jsonHolder;
23
24
    /**
25
     * @param JsonHolder $jsonHolder
26
     */
27
    public function __construct(JsonHolder $jsonHolder)
28
    {
29
        $this->jsonHolder = $jsonHolder;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function initializeContext(Context $context)
36
    {
37
        if ($context instanceof JsonHolderAware) {
38
            $context->setJsonHolder($this->jsonHolder);
39
        }
40
    }
41
42
}
43