Failed Conditions
Push — master ( 1499d5...f007c6 )
by Florent
01:58
created

JWSBuilder::prepend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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\Signature\DependencyInjection\Source;
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 AbstractSource
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function name(): string
31
    {
32
        return 'jws_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