Passed
Push — master ( 4ee9ec...849354 )
by San
04:18 queued 03:37
created

Extension   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 5
dl 0
loc 51
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigKey() 0 4 1
A initialize() 0 3 1
A process() 0 3 1
A load() 0 8 1
A configure() 0 3 1
A loadClassResolver() 0 6 1
A loadHttpCallListener() 0 10 2
A getCompilerPasses() 0 4 1
1
<?php
2
3
namespace Behatch;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Definition;
9
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
10
use Behat\Behat\Context\ServiceContainer\ContextExtension;
11
use Behat\Testwork\ServiceContainer\ExtensionManager;
12
use Behat\Testwork\ServiceContainer\Extension as ExtensionInterface;
13
14
class Extension implements ExtensionInterface
15
{
16
    public function getConfigKey()
17
    {
18
        return 'behatch';
19
    }
20
21
    public function initialize(ExtensionManager $extensionManager)
22
    {
23
    }
24
25
    public function process(ContainerBuilder $container)
26
    {
27
    }
28
29
    public function load(ContainerBuilder $container, array $config)
30
    {
31
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/Resources/services'));
32
        $loader->load('http_call.yml');
33
34
        $this->loadClassResolver($container);
35
        $this->loadHttpCallListener($container);
36
    }
37
38
    public function configure(ArrayNodeDefinition $builder)
39
    {
40
    }
41
42
    private function loadClassResolver(ContainerBuilder $container)
43
    {
44
        $definition = new Definition('Behatch\Context\ContextClass\ClassResolver');
45
        $definition->addTag(ContextExtension::CLASS_RESOLVER_TAG);
46
        $container->setDefinition('behatch.class_resolver', $definition);
47
    }
48
49
    private function loadHttpCallListener(ContainerBuilder $container)
50
    {
51
        $processor = new \Behat\Testwork\ServiceContainer\ServiceProcessor;
52
        $references = $processor->findAndSortTaggedServices($container, 'behatch.context_voter');
53
        $definition = $container->getDefinition('behatch.context_supported.voter');
54
55
        foreach ($references as $reference) {
56
            $definition->addMethodCall('register', [$reference]);
57
        }
58
    }
59
60
    public function getCompilerPasses()
61
    {
62
        return [];
63
    }
64
}
65