Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 82
dl 0
loc 89
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 87 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - https://ziku.la/
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 Zikula\UsersBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17
use Symfony\Component\Config\Definition\ConfigurationInterface;
18
19
class Configuration implements ConfigurationInterface
20
{
21
    public function getConfigTreeBuilder(): TreeBuilder
22
    {
23
        $treeBuilder = new TreeBuilder('zikula_users');
24
25
        $treeBuilder->getRootNode()
26
            ->children()
27
                ->booleanNode('allow_self_deletion')
28
                    ->info('Allow users to delete themselves.')
29
                    ->defaultFalse()
30
                ->end()
31
                ->arrayNode('registration')
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

31
                ->/** @scrutinizer ignore-call */ arrayNode('registration')
Loading history...
32
                    ->info('Registration settings.')
33
                    ->addDefaultsIfNotSet()
34
                    ->children()
35
                        ->booleanNode('enabled')
36
                            ->info('Allow new user account registrations.')
37
                            ->defaultTrue()
38
                        ->end()
39
                        ->scalarNode('disabled_reason')
40
                            ->info('Statement displayed if registration disabled.')
41
                            ->defaultValue('Sorry! New user registration is currently disabled.')
42
                        ->end()
43
                        ->scalarNode('admin_notification_mail')
44
                            ->info('E-mail address to notify of registrations (leave blank for no notifications).')
45
                            ->defaultNull()
46
                            ->validate()
47
                                ->ifTrue(static function ($v) {
48
                                    return null !== $v && !filter_var($v, FILTER_VALIDATE_EMAIL);
49
                                })
50
                                ->thenInvalid('Please enter a valid mail address.')
51
                            ->end()
52
                        ->end()
53
                    ->end()
54
                ->end()
55
                ->booleanNode('display_registration_date')
56
                    ->info('Display the user\'s registration date.')
57
                    ->defaultFalse()
58
                ->end()
59
                ->arrayNode('avatar')
60
                    ->info('Avatar settings.')
61
                    ->addDefaultsIfNotSet()
62
                    ->children()
63
                        ->scalarNode('image_path')
64
                            ->info('Path to user\'s avatar images.')
65
                            ->defaultValue('public/uploads/avatar')
66
                        ->end()
67
                        ->scalarNode('default_image')
68
                            ->info('Default avatar image (used as fallback).')
69
                            ->defaultValue('gravatar.jpg')
70
                        ->end()
71
                        ->booleanNode('gravatar_enabled')
72
                            ->info('Allow usage of Gravatar.')
73
                            ->defaultTrue()
74
                        ->end()
75
                        ->arrayNode('uploads')
76
                            ->info('Allow uploading custom avatar images.')
77
                            ->canBeEnabled()
78
                            ->children()
79
                                ->booleanNode('shrink_large_images')
80
                                    ->info('Shrink large images to maximum dimensions.')
81
                                    ->defaultTrue()
82
                                ->end()
83
                                ->integerNode('max_size')
84
                                    ->info('Max. avatar filesize in bytes.')
85
                                    ->defaultValue(12000)
86
                                    ->min(1)
87
                                ->end()
88
                                ->integerNode('max_width')
89
                                    ->info('Max. avatar width in pixels.')
90
                                    ->defaultValue(80)
91
                                    ->min(1)
92
                                    ->max(9999)
93
                                ->end()
94
                                ->integerNode('max_height')
95
                                    ->info('Max. avatar height in pixels.')
96
                                    ->defaultValue(80)
97
                                    ->min(1)
98
                                    ->max(9999)
99
                                ->end()
100
                            ->end()
101
                        ->end()
102
                    ->end()
103
                ->end()
104
            ->end()
105
        ;
106
107
        return $treeBuilder;
108
    }
109
}
110