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

JWSBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 4 1
A load() 0 14 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\Signature;
15
16
use Jose\Component\Signature\JWSBuilderFactory;
17
use Jose\Component\Signature\JWSBuilder as JWSBuilderService;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Definition;
20
use Symfony\Component\DependencyInjection\Reference;
21
22
/**
23
 * Class JWSBuilder.
24
 */
25
final class JWSBuilder extends AbstractSignatureSource
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function name(): string
31
    {
32
        return 'builders';
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.jws_builder.%s', $name);
42
            $definition = new Definition(JWSBuilderService::class);
43
            $definition
44
                ->setFactory([new Reference(JWSBuilderFactory::class), 'create'])
45
                ->setArguments([$itemConfig['signature_algorithms']])
46
                ->addTag('jose.jws_builder')
47
                ->setPublic($itemConfig['is_public']);
48
49
            $container->setDefinition($service_id, $definition);
50
        }
51
    }
52
}
53