Failed Conditions
Push — master ( df81c3...a4880e )
by Florent
02:26
created

AbstractEncryptionSource::getNodeDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 48
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 9.125
c 0
b 0
f 0
cc 1
eloc 46
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Bundle\JoseFramework\DependencyInjection\Source\Encryption;
15
16
use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source;
17
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
abstract class AbstractEncryptionSource implements Source
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getNodeDefinition(NodeDefinition $node)
26
    {
27
        $node
28
            ->children()
29
                ->arrayNode($this->name())
30
                    ->useAttributeAsKey('name')
31
                    ->arrayPrototype()
32
                        ->children()
33
                            ->booleanNode('is_public')
34
                                ->info('If true, the service will be public, else private.')
35
                                ->defaultTrue()
36
                            ->end()
37
                            ->arrayNode('key_encryption_algorithms')
38
                                ->info('A list of supported key encryption algorithms.')
39
                                ->useAttributeAsKey('name')
40
                                ->isRequired()
41
                                ->cannotBeEmpty()
42
                                ->requiresAtLeastOneElement()
43
                                ->scalarPrototype()->end()
44
                            ->end()
45
                            ->arrayNode('content_encryption_algorithms')
46
                                ->info('A list of supported content encryption algorithms.')
47
                                ->useAttributeAsKey('name')
48
                                ->isRequired()
49
                                ->cannotBeEmpty()
50
                                ->requiresAtLeastOneElement()
51
                                ->scalarPrototype()->end()
52
                            ->end()
53
                            ->arrayNode('compression_methods')
54
                                ->info('A list of supported compression methods.')
55
                                ->useAttributeAsKey('name')
56
                                ->defaultValue(['DEF'])
57
                                ->cannotBeEmpty()
58
                                ->requiresAtLeastOneElement()
59
                                ->scalarPrototype()->end()
60
                            ->end()
61
                            ->arrayNode('tags')
62
                                ->info('A list of tags to be associated to the service.')
63
                                ->useAttributeAsKey('name')
64
                                ->treatNullLike([])
65
                                ->treatFalseLike([])
66
                                ->prototype('variable')->end()
67
                            ->end()
68
                        ->end()
69
                    ->end()
70
                ->end()
71
            ->end();
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function prepend(ContainerBuilder $container, array $config): array
78
    {
79
        return [];
80
    }
81
}
82