JWEBuilderFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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