Completed
Push — master ( ef5d35...9af83e )
by Thomas
12s queued 10s
created

getSubstituteOriginalDrupalKernelConfigNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 15
ccs 14
cts 14
cp 1
crap 1
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the ekino Drupal Debug project.
7
 *
8
 * (c) ekino
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ekino\Drupal\Debug\Configuration;
15
16
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
17
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
18
use Symfony\Component\Config\Definition\ConfigurationInterface;
19
20
class Configuration implements ConfigurationInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 4
    public function getConfigTreeBuilder(): TreeBuilder
26
    {
27 4
        $treeBuilder = new TreeBuilder();
28
        /** @var ArrayNodeDefinition $rootNode */
29 4
        $rootNode = $treeBuilder->root('drupal-debug');
30
31
        $rootNode
32 4
            ->info('This is the drupal-debug configuration file.')
33 4
            ->children()
34 4
                ->append($this->getDefaultsConfigNode())
35 4
                ->append($this->getSubstituteOriginalDrupalKernelConfigNode())
36 4
            ->end();
37
38 4
        return $treeBuilder;
39
    }
40
41
    /**
42
     * @return ArrayNodeDefinition
43
     */
44 4
    private function getDefaultsConfigNode(): ArrayNodeDefinition
45
    {
46 4
        return (new ArrayNodeDefinition('defaults'))
47 4
            ->info('The defaults values are common values that are reused by different actions.')
48 4
            ->addDefaultsIfNotSet()
49 4
            ->children()
50 4
                ->scalarNode('cache_directory')
51 4
                    ->cannotBeEmpty()
52 4
                    ->defaultValue('cache')
53 4
                ->end()
54 4
                ->arrayNode('logger')
0 ignored issues
show
Bug introduced by
The method arrayNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

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

54
                ->/** @scrutinizer ignore-call */ arrayNode('logger')
Loading history...
55 4
                    ->canBeDisabled()
56 4
                    ->children()
57 4
                        ->scalarNode('channel')
58 4
                            ->cannotBeEmpty()
59 4
                            ->defaultValue('drupal-debug')
60 4
                        ->end()
61 4
                        ->scalarNode('file_path')
62 4
                            ->cannotBeEmpty()
63 4
                            ->defaultValue('logs/drupal-debug.log')
64 4
                        ->end()
65 4
                    ->end()
66 4
                ->end()
67 4
                ->scalarNode('charset')
68 4
                    ->defaultNull()
69 4
                ->end()
70 4
                ->scalarNode('file_link_format')
71 4
                    ->defaultNull()
72 4
                ->end()
73 4
            ->end();
74
    }
75
76
    /**
77
     * @return ArrayNodeDefinition
78
     */
79 4
    private function getSubstituteOriginalDrupalKernelConfigNode(): ArrayNodeDefinition
80
    {
81 4
        return (new ArrayNodeDefinition('substitute_original_drupal_kernel'))
82 4
            ->info("It is recommended to disable the original DrupalKernel substitution to run your tests.\nTo programmatically toggle it, use the two dedicated composer commands.")
83 4
            ->canBeDisabled()
84 4
            ->children()
85 4
                ->scalarNode('composer_autoload_file_path')
86 4
                    ->cannotBeEmpty()
87 4
                    ->defaultValue('vendor/autoload.php')
88 4
                ->end()
89 4
                ->scalarNode('cache_directory')
0 ignored issues
show
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

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

89
                ->/** @scrutinizer ignore-call */ scalarNode('cache_directory')
Loading history...
90 4
                    ->info('If not specified, it fall backs to the default cache directory.')
91 4
                    ->defaultNull()
92 4
                ->end()
93 4
            ->end();
94
    }
95
}
96