Passed
Branch main (b6a268)
by Iain
04:04
created

Funnel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handleDefaultParameters() 0 2 1
A handleConfiguration() 0 11 4
A addConfig() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright Humbly Arrogant Ltd 2020-2022.
7
 *
8
 * Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license.
9
 *
10
 * Change Date: TBD ( 3 years after 2.0.0 release )
11
 *
12
 * On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file.
13
 */
14
15
namespace Parthenon\DependencyInjection\Modules;
16
17
use Parthenon\Funnel\Repository\FunnelRepositoryInterface;
18
use Parthenon\Funnel\UnfinnishedActions\ActionInterface;
19
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
20
use Symfony\Component\Config\FileLocator;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...ection\ContainerBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...on\Loader\XmlFileLoader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
24
final class Funnel implements ModuleConfigurationInterface
25
{
26
    public function addConfig(NodeBuilder $nodeBuilder): void
27
    {
28
        $nodeBuilder
29
            ->arrayNode('funnel')
30
                ->children()
31
                    ->booleanNode('enabled')->end()
32
                ->end()
0 ignored issues
show
Bug introduced by
The method end() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
                ->/** @scrutinizer ignore-call */ end()
Loading history...
33
            ->end();
34
    }
35
36
    public function handleDefaultParameters(ContainerBuilder $container): void
37
    {
38
        // TODO: Implement handleDefaultParameters() method.
39
    }
40
41
    public function handleConfiguration(array $config, ContainerBuilder $container): void
42
    {
43
        if (!isset($config['funnel']) || !isset($config['funnel']['enabled']) || false == $config['funnel']['enabled']) {
44
            return;
45
        }
46
47
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../Resources/config'));
48
        $loader->load('services/funnel.xml');
49
50
        $container->registerForAutoconfiguration(ActionInterface::class)->addTag('parthenon.funnel.action');
51
        $container->registerForAutoconfiguration(FunnelRepositoryInterface::class)->addTag('parthenon.funnel.repository');
52
    }
53
}
54