GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

loadPlaceholdersRepository()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
namespace Ciandt\Behat\PlaceholdersExtension\ServiceContainer;
3
4
use Behat\Behat\Context\ServiceContainer\ContextExtension;
5
use Behat\Behat\Gherkin\ServiceContainer\GherkinExtension;
6
use Behat\Behat\Tester\ServiceContainer\TesterExtension;
7
use Behat\Behat\Transformation\ServiceContainer\TransformationExtension;
8
use Behat\Testwork\Cli\ServiceContainer\CliExtension;
9
use Behat\Testwork\EventDispatcher\ServiceContainer\EventDispatcherExtension;
10
use Behat\Testwork\ServiceContainer\Extension;
11
use Behat\Testwork\ServiceContainer\ExtensionManager;
12
use Ciandt\Behat\PlaceholdersExtension\Utils\PlaceholderUtils;
13
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Definition;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
final class PlaceholdersExtension implements Extension
19
{
20
21
    const PLACEHOLDERS_REPLACER_ID = 'placeholders.replacer';
22
    const PLACEHOLDERS_REPOSITIORY_ID = 'placeholders.repository';
23
    const PLACEHOLDERS_CONTROLLER_ID = 'placeholders.controller';
24
    const PLACEHOLDERS_TRANSFORMER_ID = 'placeholders.transformer';
25
    const VARIANTS_PREPROCESSOR_ID = 'placeholders.variants_preprocessor';
26
    const STEPS_DECORATOR_ID = 'placeholders.steps_decorator';
27
    const BEFORE_SCENARIO_SUBSCRIBER_ID = 'placeholders.before_scenario';
28
    const CONTEXT_INITIALIZER_ID = 'placeholders.context_initializer';
29
30
    /**
31
     * Returns the extension config key.
32
     *
33
     * @return string
34
     */
35
    public function getConfigKey()
36
    {
37
        return 'placeholders';
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function process(ContainerBuilder $container)
44
    {
45
        
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function initialize(ExtensionManager $extensionManager)
52
    {
53
        
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function configure(ArrayNodeDefinition $builder)
60
    {
61
        $builder
62
            ->addDefaultsIfNotSet()
63
            ->children()
64
            ->arrayNode('variant_tags')
65
            ->treatNullLike(array())
66
            ->info('Variant tags to iterate through')
67
            ->prototype('scalar')->end()
68
            ->end()
69
            ->arrayNode('config_tags')
70
            ->treatNullLike(array())
71
            ->useAttributeAsKey('tag')
72
            ->prototype('scalar')->end()
73
            ->end()
74
            ->end()
75
            ->end();
76
    }
77
78
    /**
79
     * Loads extension services into temporary container.
80
     *
81
     * @param ContainerBuilder $container
82
     * @param array $config
83
     */
84
    public function load(ContainerBuilder $container, array $config)
85
    {
86
        $this->initializePlaceholderUtils($config['variant_tags'], $config['config_tags']);
87
        $this->loadScenarioBranchingFileLoader($container);
88
        $this->loadPlaceholdersRepository($container, $config['config_tags']);
89
        $this->loadPlaceholdersController($container);
90
        $this->loadBeforeScenarioSubscriber($container);
91
        $this->loadPlaceholdersTransformer($container);
92
        $this->loadContextInitializer($container);
93
    }
94
95
    /**
96
     * @param ContainerBuilder $container
97
     */
98 View Code Duplication
    private function loadPlaceholdersController(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
99
    {
100
        $definition = new Definition('Ciandt\Behat\PlaceholdersExtension\Cli\PlaceholdersController', array(
101
            new Reference(self::PLACEHOLDERS_REPOSITIORY_ID)));
102
        $definition->addTag(CliExtension::CONTROLLER_TAG, array('priority' => 1));
103
        $container->setDefinition(self::PLACEHOLDERS_CONTROLLER_ID, $definition);
104
    }
105
106
    protected function initializePlaceholderUtils($variantTags, $configTags)
107
    {
108
        PlaceholderUtils::setVariantTags($variantTags);
109
        PlaceholderUtils::setConfigKeys(array_keys($configTags));
110
    }
111
112
113
    /**
114
     *
115
     * @param ContainerBuilder $container
116
     */
117
    protected function loadPlaceholdersRepository(ContainerBuilder $container, $configs_mapping)
118
    {
119
        $definition = new Definition('Ciandt\Behat\PlaceholdersExtension\Config\PlaceholdersRepository', array(
120
            $configs_mapping,
121
            new Reference(self::BEFORE_SCENARIO_SUBSCRIBER_ID)
122
        ));
123
        $container->setDefinition(self::PLACEHOLDERS_REPOSITIORY_ID, $definition);
124
    }
125
126
    /**
127
     *
128
     * @param ContainerBuilder $container
129
     */
130
    protected function loadScenarioBranchingFileLoader(ContainerBuilder $container)
131
    {
132
        $definition = new Definition('Ciandt\Behat\PlaceholdersExtension\Gherkin\ScenarioBranchingFileLoader', array(
133
            new Reference('gherkin.parser'),
134
            new Definition('Behat\Gherkin\Cache\MemoryCache')
135
        ));
136
        $definition->addTag(GherkinExtension::LOADER_TAG, array('priority' => 100));
137
        $container->setDefinition(self::VARIANTS_PREPROCESSOR_ID, $definition);
138
    }
139
140
141
    /**
142
     * Loads transformers.
143
     *
144
     * @param ContainerBuilder $container
145
     */
146 View Code Duplication
    protected function loadPlaceholdersTransformer(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
147
    {
148
        $definition = new Definition('Ciandt\Behat\PlaceholdersExtension\Transformer\PlaceholdersTransformer', array(
149
            new Reference(self::PLACEHOLDERS_REPOSITIORY_ID)
150
        ));
151
        $definition->addTag(TransformationExtension::ARGUMENT_TRANSFORMER_TAG, array('priority' => 9999999));
152
        $container->setDefinition(self::PLACEHOLDERS_TRANSFORMER_ID, $definition);
153
    }
154
    
155
156 View Code Duplication
    protected function loadStepDecoratingScenarioTester(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
157
    {
158
        $definition = new Definition('Ciandt\Behat\PlaceholdersExtension\Tester\StepDecoratingScenarioTester', array(
159
            new Reference(TesterExtension::SCENARIO_TESTER_ID)
160
        ));
161
        $definition->addTag(TesterExtension::SCENARIO_TESTER_WRAPPER_TAG, array('priority' => 9999999));
162
        $container->setDefinition(self::STEPS_DECORATOR_ID, $definition);
163
    }
164
    
165
    protected function loadBeforeScenarioSubscriber(ContainerBuilder $container)
166
    {
167
        $definition = new Definition('Ciandt\Behat\PlaceholdersExtension\Subscriber\BeforeScenarioSubscriber');
168
        $definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, array('priority' => 0));
169
        $container->setDefinition(self::BEFORE_SCENARIO_SUBSCRIBER_ID, $definition);
170
    }
171
    
172 View Code Duplication
    private function loadContextInitializer(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
173
    {
174
        $definition = new Definition('Ciandt\Behat\PlaceholdersExtension\Initializer\PlaceholdersAwareInitializer', array(
175
            new Reference(self::PLACEHOLDERS_REPOSITIORY_ID)
176
        ));
177
        $definition->addTag(ContextExtension::INITIALIZER_TAG, array('priority' => 0));
178
        $container->setDefinition(self::CONTEXT_INITIALIZER_ID, $definition);
179
    }
180
}
181