Test Failed
Pull Request — feature/publishable (#31)
by Vincent
06:55
created

Configuration::addPublishableNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 13
rs 9.9
ccs 11
cts 11
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Component Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentBundle\DependencyInjection;
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
/**
21
 * @author Daniel West <[email protected]>
22
 */
23
class Configuration implements ConfigurationInterface
24
{
25 1
    public function getConfigTreeBuilder(): TreeBuilder
26
    {
27 1
        $treeBuilder = new TreeBuilder('silverback_api_component');
28 1
        $rootNode = $treeBuilder->getRootNode();
29
        $rootNode
30 1
            ->children()
31 1
                ->scalarNode('website_name')->isRequired()->end()
32 1
                ->scalarNode('table_prefix')->defaultValue('_acb_')->end()
33 1
            ->end();
34
35 1
        $this->addPublishableNode($rootNode);
36 1
        $this->addSecurityNode($rootNode);
37 1
        $this->addEnabledComponentsNode($rootNode);
38
        $this->addUserNode($rootNode);
39 1
40
        return $treeBuilder;
41
    }
42 1
43
    private function addPublishableNode(ArrayNodeDefinition $rootNode): void
44
    {
45 1
        $rootNode
46 1
            ->children()
47 1
                ->arrayNode('publishable')
48 1
                    ->addDefaultsIfNotSet()
49 1
                    ->children()
50 1
                        ->scalarNode('permission')
51 1
                            ->cannotBeEmpty()
52 1
                        ->end()
53 1
                    ->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

53
                    ->/** @scrutinizer ignore-call */ end()
Loading history...
54 1
                ->end()
55 1
            ->end();
56
    }
57 1
58
    private function addSecurityNode(ArrayNodeDefinition $rootNode): void
59
    {
60 1
        $rootNode
61 1
            ->children()
62 1
                ->arrayNode('security')
63 1
                    ->addDefaultsIfNotSet()
64 1
                    ->children()
65 1
                        ->arrayNode('tokens')
66 1
                            ->prototype('scalar')->end()
67 1
                        ->end()
68 1
                    ->end()
69 1
                ->end()
70
            ->end();
71 1
    }
72
73
    private function addEnabledComponentsNode(ArrayNodeDefinition $rootNode): void
74 1
    {
75 1
        $rootNode
76 1
            ->children()
77 1
                ->arrayNode('enabled_components')
78 1
                    ->addDefaultsIfNotSet()
79 1
                    ->children()
80 1
                        ->booleanNode('form')->defaultValue(true)->end()
81 1
                        ->booleanNode('collection')->defaultValue(true)->end()
0 ignored issues
show
Bug introduced by
The method booleanNode() 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

81
                        ->/** @scrutinizer ignore-call */ booleanNode('collection')->defaultValue(true)->end()
Loading history...
82 1
                    ->end()
83 1
                ->end()
84 1
            ->end();
85 1
    }
86 1
87 1
    private function addUserNode(ArrayNodeDefinition $rootNode): void
88 1
    {
89 1
        $rootNode
90 1
            ->children()
91 1
                ->arrayNode('user')
92 1
                    ->addDefaultsIfNotSet()
93 1
                    ->children()
94 1
                        ->scalarNode('class_name')->isRequired()->end()
95 1
                        ->arrayNode('email_verification')
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

95
                        ->/** @scrutinizer ignore-call */ arrayNode('email_verification')
Loading history...
96 1
                            ->canBeDisabled()
97 1
                            ->addDefaultsIfNotSet()
98 1
                            ->children()
99 1
                                ->arrayNode('email')
100 1
                                    ->children()
101 1
                                        ->scalarNode('redirect_path_query')->end()
102 1
                                        ->scalarNode('default_redirect_path')->isRequired()->end()
103 1
                                        ->scalarNode('subject')->cannotBeEmpty()->defaultValue('Please verify your email')->end()
104 1
                                    ->end()
105 1
                                ->end()
106 1
                                ->booleanNode('default_value')->isRequired()->end()
107 1
                                ->booleanNode('verify_on_change')->isRequired()->end()
108 1
                                ->booleanNode('verify_on_register')->isRequired()->end()
109 1
                                ->booleanNode('deny_unverified_login')->isRequired()->end()
110 1
                            ->end()
111 1
                        ->end()
112 1
                        ->arrayNode('password_reset')
113 1
                            ->addDefaultsIfNotSet()
114 1
                            ->children()
115 1
                                ->arrayNode('email')
116 1
                                    ->children()
117 1
                                        ->scalarNode('redirect_path_query')->end()
118 1
                                        ->scalarNode('default_redirect_path')->isRequired()->end()
119 1
                                        ->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your password has been reset')->end()
120 1
                                    ->end()
121 1
                                ->end()
122 1
                                ->integerNode('repeat_ttl_seconds')->defaultValue(8600)->end()
123 1
                                ->integerNode('request_timeout_seconds')->defaultValue(3600)->end()
124 1
                            ->end()
125 1
                        ->end()
126 1
                        ->arrayNode('emails')
127 1
                            ->addDefaultsIfNotSet()
128 1
                            ->children()
129 1
                                ->arrayNode('welcome')
130 1
                                    ->canBeDisabled()
131 1
                                    ->addDefaultsIfNotSet()
132 1
                                    ->children()
133 1
                                        ->scalarNode('subject')->cannotBeEmpty()->defaultValue('Welcome to {{ website_name }}')->end()
134 1
                                    ->end()
135 1
                                ->end()
136 1
                                ->arrayNode('user_enabled')
137 1
                                    ->canBeDisabled()
138 1
                                    ->addDefaultsIfNotSet()
139 1
                                    ->children()
140 1
                                        ->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your account has been enabled')->end()
141 1
                                    ->end()
142 1
                                ->end()
143 1
                                ->arrayNode('username_changed')
144 1
                                    ->canBeDisabled()
145 1
                                    ->addDefaultsIfNotSet()
146 1
                                    ->children()
147
                                        ->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your username has been updated')->end()
148
                                    ->end()
149
                                ->end()
150
                                ->arrayNode('password_changed')
151
                                    ->canBeDisabled()
152
                                    ->addDefaultsIfNotSet()
153
                                    ->children()
154
                                        ->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your password has been changed')->end()
155
                                    ->end()
156
                                ->end()
157
                            ->end()
158
                        ->end()
159
                    ->end()
160
                ->end()
161
            ->end();
162
    }
163
}
164