JWEDecrypterFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 34
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-2019 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\AlgorithmManagerFactory;
17
use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory;
18
19
class JWEDecrypterFactory
20
{
21
    /**
22
     * @var AlgorithmManagerFactory
23
     */
24
    private $algorithmManagerFactory;
25
26
    /**
27
     * @var CompressionMethodManagerFactory
28
     */
29
    private $compressionMethodManagerFactory;
30
31
    public function __construct(AlgorithmManagerFactory $algorithmManagerFactory, CompressionMethodManagerFactory $compressionMethodManagerFactory)
32
    {
33
        $this->algorithmManagerFactory = $algorithmManagerFactory;
34
        $this->compressionMethodManagerFactory = $compressionMethodManagerFactory;
35
    }
36
37
    /**
38
     * Creates a JWE Decrypter object using the given key encryption algorithms, content encryption algorithms and compression methods.
39
     *
40
     * @param string[] $keyEncryptionAlgorithms
41
     * @param string[] $contentEncryptionAlgorithms
42
     * @param string[] $compressionMethods
43
     */
44
    public function create(array $keyEncryptionAlgorithms, array $contentEncryptionAlgorithms, array $compressionMethods): JWEDecrypter
45
    {
46
        $keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms);
47
        $contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithms);
48
        $compressionMethodManager = $this->compressionMethodManagerFactory->create($compressionMethods);
49
50
        return new JWEDecrypter($keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager);
51
    }
52
}
53