Failed Conditions
Pull Request — master (#47)
by Florent
06:42
created

JWEDecrypter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 4 1
A load() 0 18 2
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\JoseFramework\DependencyInjection\Source\Encryption;
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 AbstractEncryptionSource
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function name(): string
31
    {
32
        return '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