Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 37
dl 0
loc 43
rs 10
c 3
b 0
f 1
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 41 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gbere\SimpleAuth\DependencyInjection;
6
7
use Gbere\SimpleAuth\Entity\AdminUser;
8
use Gbere\SimpleAuth\Entity\User;
9
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
10
use Symfony\Component\Config\Definition\ConfigurationInterface;
11
12
class Configuration implements ConfigurationInterface
13
{
14
    public function getConfigTreeBuilder()
15
    {
16
        $treeBuilder = new TreeBuilder('gbere_simple_auth');
17
        $rootNode = $treeBuilder->getRootNode();
18
        $rootNode
19
            ->children()
20
                ->arrayNode('sender')
21
                ->addDefaultsIfNotSet()
22
                    ->children()
23
                        // TODO: check if it is a valid email
24
                        ->scalarNode('email')->defaultValue('[email protected]')->end()
25
                        ->scalarNode('name')->defaultValue('Sender Name')->end()
26
                    ->end()
27
                ->end()
28
                ->arrayNode('user')
29
                ->addDefaultsIfNotSet()
30
                    ->children()
31
                        ->scalarNode('entity')->defaultValue(User::class)->info('If you want to extend the entity, the entity name must also be "User". Example: App/Entity/User')->end()
32
                        ->scalarNode('encoder_algorithm')->defaultValue('auto')->end()
33
                    ->end()
34
                ->end()
35
                ->arrayNode('admin_user')
36
                ->addDefaultsIfNotSet()
37
                    ->children()
38
                        ->scalarNode('entity')->defaultValue(AdminUser::class)->info('If you want to extend the entity, the entity name must also be "AdminUser". Example: App/Entity/AdminUser')->end()
39
                        ->scalarNode('encoder_algorithm')->defaultValue('auto')->end()
40
                    ->end()
41
                ->end()
42
                ->arrayNode('style')
43
                ->addDefaultsIfNotSet()
44
                    ->children()
45
                        ->scalarnode('logo')->defaultValue('demo')->info('Define a custom path, disable it with ~ char or set demo image')->end()
46
                        ->scalarnode('accent_color')->defaultValue('0088aa')->info('Set color in RGB hexadecimal without the #')->end()
47
                    ->end()
48
                ->end()
49
                ->integerNode('remember_me_lifetime')->defaultValue(null)->end()
50
                ->booleanNode('confirm_registration')->defaultValue(true)->end()
51
            ->end()
52
        ;
53
54
        return $treeBuilder;
55
    }
56
}
57