JWSBuilderFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
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\Component\Signature;
15
16
use Jose\Component\Core\Converter\JsonConverterInterface;
17
use Jose\Component\Core\AlgorithmManagerFactory;
18
19
/**
20
 * Class JWSBuilderFactory.
21
 */
22
final class JWSBuilderFactory
23
{
24
    /**
25
     * @var JsonConverterInterface
26
     */
27
    private $jsonEncoder;
28
29
    /**
30
     * @var AlgorithmManagerFactory
31
     */
32
    private $signatureAlgorithmManagerFactory;
33
34
    /**
35
     * JWSBuilderFactory constructor.
36
     *
37
     * @param JsonConverterInterface  $jsonEncoder
38
     * @param AlgorithmManagerFactory $signatureAlgorithmManagerFactory
39
     */
40
    public function __construct(JsonConverterInterface $jsonEncoder, AlgorithmManagerFactory $signatureAlgorithmManagerFactory)
41
    {
42
        $this->jsonEncoder = $jsonEncoder;
43
        $this->signatureAlgorithmManagerFactory = $signatureAlgorithmManagerFactory;
44
    }
45
46
    /**
47
     * @param string[] $algorithms
48
     *
49
     * @return JWSBuilder
50
     */
51
    public function create(array $algorithms): JWSBuilder
52
    {
53
        $algorithmManager = $this->signatureAlgorithmManagerFactory->create($algorithms);
54
55
        return new JWSBuilder($this->jsonEncoder, $algorithmManager);
56
    }
57
}
58