Failed Conditions
Push — v7 ( 79e5af...524357 )
by Florent
02:58
created

JWEBuilderFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 8 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\Component\Encryption;
15
16
use Jose\Component\Core\JWAManagerFactory;
17
use Jose\Component\Encryption\Compression\CompressionMethodsManagerFactory;
18
19
final class JWEBuilderFactory
20
{
21
    /**
22
     * @var JWAManagerFactory
23
     */
24
    private $algorithmManagerFactory;
25
26
    /**
27
     * @var CompressionMethodsManagerFactory
28
     */
29
    private $compressionMethodManagerFactory;
30
31
    /**
32
     * JWEBuilder constructor.
33
     *
34
     * @param JWAManagerFactory                $algorithmManagerFactory
35
     * @param CompressionMethodsManagerFactory $compressionMethodManagerFactory
36
     */
37
    public function __construct(JWAManagerFactory $algorithmManagerFactory, CompressionMethodsManagerFactory $compressionMethodManagerFactory)
38
    {
39
        $this->algorithmManagerFactory = $algorithmManagerFactory;
40
        $this->compressionMethodManagerFactory = $compressionMethodManagerFactory;
41
    }
42
43
    /**
44
     * @param string[] $keyEncryptionAlgorithms
45
     * @param string[] $contentEncryptionAlgorithm
46
     * @param string[] $compressionMethods
47
     *
48
     * @return JWEBuilder
49
     */
50
    public function create(array $keyEncryptionAlgorithms, array $contentEncryptionAlgorithm, array $compressionMethods): JWEBuilder
51
    {
52
        $keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms);
53
        $contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithm);
54
        $compressionMethodManager = $this->compressionMethodManagerFactory->create($compressionMethods);
55
56
        return new JWEBuilder($keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager);
57
    }
58
}
59