Completed
Push — master ( a329ed...6bc113 )
by Yo
02:08
created

BehatContextSubscriberInitializer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 22
c 1
b 0
f 0
wmc 3
lcom 1
cbo 1
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A initializeContext() 0 8 2
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\EventDispatcher\EventDispatcherInterface;
7
use Yoanm\Behat3SymfonyExtension\Context\BehatContextSubscriberInterface;
8
9
/**
10
 * Class BehatContextSubscriberInitializer
11
 */
12
class BehatContextSubscriberInitializer implements ContextInitializer
13
{
14
    /** @var EventDispatcherInterface */
15
    private $behatEventDispatcher;
16
17 2
    public function __construct(EventDispatcherInterface $behatEventDispatcher)
18
    {
19 2
        $this->behatEventDispatcher = $behatEventDispatcher;
20 2
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 2
    public function initializeContext(Context $context)
26
    {
27 2
        if (!$context instanceof BehatContextSubscriberInterface) {
28 1
            return;
29
        }
30
31 1
        $this->behatEventDispatcher->addSubscriber($context);
32 1
    }
33
}
34