Failed Conditions
Push — master ( 5537f8...d96005 )
by Florent
02:00
created

JWEDecrypterFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
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\Checker\HeaderCheckerManagerFactory;
17
use Jose\Component\Core\AlgorithmManagerFactory;
18
use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory;
19
20
/**
21
 * Class JWEDecrypterFactory.
22
 */
23
final class JWEDecrypterFactory
24
{
25
    /**
26
     * @var AlgorithmManagerFactory
27
     */
28
    private $algorithmManagerFactory;
29
30
    /**
31
     * @var CompressionMethodManagerFactory
32
     */
33
    private $compressionMethodManagerFactory;
34
35
    /**
36
     * @var HeaderCheckerManagerFactory
37
     */
38
    private $headerCheckerManagerFactory;
39
40
    /**
41
     * JWEDecrypterFactory constructor.
42
     *
43
     * @param AlgorithmManagerFactory         $algorithmManagerFactory
44
     * @param CompressionMethodManagerFactory $compressionMethodManagerFactory
45
     * @param HeaderCheckerManagerFactory     $headerCheckerManagerFactory
46
     */
47
    public function __construct(AlgorithmManagerFactory $algorithmManagerFactory, CompressionMethodManagerFactory $compressionMethodManagerFactory, HeaderCheckerManagerFactory $headerCheckerManagerFactory)
48
    {
49
        $this->algorithmManagerFactory = $algorithmManagerFactory;
50
        $this->compressionMethodManagerFactory = $compressionMethodManagerFactory;
51
        $this->headerCheckerManagerFactory = $headerCheckerManagerFactory;
52
    }
53
54
    /**
55
     * @param string[] $keyEncryptionAlgorithms
56
     * @param string[] $contentEncryptionAlgorithms
57
     * @param string[] $compressionMethods
58
     * @param string[] $headerCheckers
59
     *
60
     * @return JWEDecrypter
61
     */
62
    public function create(array $keyEncryptionAlgorithms, array $contentEncryptionAlgorithms, array $compressionMethods, array $headerCheckers): JWEDecrypter
63
    {
64
        $keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms);
65
        $contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithms);
66
        $compressionMethodManager = $this->compressionMethodManagerFactory->create($compressionMethods);
67
        $headerCheckerManager = $this->headerCheckerManagerFactory->create($headerCheckers);
68
69
        return new JWEDecrypter($keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager, $headerCheckerManager);
70
    }
71
}
72