Failed Conditions
Push — master ( f007c6...5a7fe0 )
by Florent
01:54
created

JWEDecrypter::getNodeDefinition()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 33
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 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\Encryption\DependencyInjection\Source;
15
16
use Jose\Component\Encryption\JWEDecrypterFactory;
17
use Jose\Component\Encryption\JWEDecrypter as JWEDecrypterService;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Definition;
20
use Symfony\Component\DependencyInjection\Reference;
21
22
/**
23
 * Class JWEDecrypter.
24
 */
25
final class JWEDecrypter extends AbstractSource
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function name(): string
31
    {
32
        return 'jwe_decrypters';
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function load(array $configs, ContainerBuilder $container)
39
    {
40
        foreach ($configs[$this->name()] as $name => $itemConfig) {
41
            $service_id = sprintf('jose.jwe_decrypter.%s', $name);
42
            $definition = new Definition(JWEDecrypterService::class);
43
            $definition
44
                ->setFactory([new Reference(JWEDecrypterFactory::class), 'create'])
45
                ->setArguments([
46
                    $itemConfig['key_encryption_algorithms'],
47
                    $itemConfig['content_encryption_algorithms'],
48
                    $itemConfig['compression_methods'],
49
                ])
50
                ->addTag('jose.jwe_decrypter')
51
                ->setPublic($itemConfig['is_public']);
52
53
            $container->setDefinition($service_id, $definition);
54
        }
55
    }
56
}
57