Configuration   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 95.24%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 43
ccs 20
cts 21
cp 0.9524
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 30 2
A addQueueOptions() 0 6 1
1
<?php
2
3
/*
4
 * Copyright 2012 Johannes M. Schmitt <[email protected]>
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace JMS\JobQueueBundle\DependencyInjection;
20
21
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
22
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
23
use Symfony\Component\Config\Definition\ConfigurationInterface;
24
25
/**
26
 * JMSJobQueueBundle Configuration.
27
 *
28
 * @author Johannes M. Schmitt <[email protected]>
29
 */
30
class Configuration implements ConfigurationInterface
31
{
32
    /**
33
     * {@inheritDoc}
34
     */
35 6
    public function getConfigTreeBuilder()
36
    {
37 6
        $treeBuilder = new TreeBuilder('jms_job_queue');
38
39 6
        if (method_exists($treeBuilder, 'getRootNode')) {
40 6
            $rootNode = $treeBuilder->getRootNode();
41
        } else {
42
            // BC layer for symfony/config 4.1 and older
43
            $rootNode = $treeBuilder->root('jms_job_queue');
0 ignored issues
show
Bug introduced by
The method root() does not seem to exist on object<Symfony\Component...on\Builder\TreeBuilder>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        }
45
46
        $rootNode
47 6
            ->children()
48 6
            ->booleanNode('statistics')->defaultTrue()->end();
49
50
        $defaultOptionsNode = $rootNode
51 6
            ->children()
52 6
            ->arrayNode('queue_options_defaults')
53 6
            ->addDefaultsIfNotSet();
54 6
        $this->addQueueOptions($defaultOptionsNode);
55
56
        $queueOptionsNode = $rootNode
57 6
            ->children()
58 6
            ->arrayNode('queue_options')
59 6
            ->useAttributeAsKey('queue')
60 6
            ->prototype('array');
61 6
        $this->addQueueOptions($queueOptionsNode);
62
63 6
        return $treeBuilder;
64
    }
65
66 6
    private function addQueueOptions(ArrayNodeDefinition $def)
67
    {
68
        $def
69 6
            ->children()
70 6
            ->scalarNode('max_concurrent_jobs')->end();
71 6
    }
72
}
73