JWELoaderFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A create() 0 10 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\Checker\HeaderCheckerManagerFactory;
17
use Jose\Component\Core\AlgorithmManagerFactory;
18
use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory;
19
use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory;
20
21
/**
22
 * Class JWELoaderFactory.
23
 */
24
final class JWELoaderFactory
25
{
26
    /**
27
     * @var AlgorithmManagerFactory
28
     */
29
    private $algorithmManagerFactory;
30
31
    /**
32
     * @var CompressionMethodManagerFactory
33
     */
34
    private $compressionMethodManagerFactory;
35
36
    /**
37
     * @var HeaderCheckerManagerFactory
38
     */
39
    private $headerCheckerManagerFactory;
40
41
    /**
42
     * @var JWESerializerManagerFactory
43
     */
44
    private $serializerManagerFactory;
45
46
    /**
47
     * JWELoaderFactory constructor.
48
     *
49
     * @param AlgorithmManagerFactory         $algorithmManagerFactory
50
     * @param CompressionMethodManagerFactory $compressionMethodManagerFactory
51
     * @param HeaderCheckerManagerFactory     $headerCheckerManagerFactory
52
     */
53
    public function __construct(AlgorithmManagerFactory $algorithmManagerFactory, CompressionMethodManagerFactory $compressionMethodManagerFactory, HeaderCheckerManagerFactory $headerCheckerManagerFactory, JWESerializerManagerFactory $serializerManagerFactory)
54
    {
55
        $this->algorithmManagerFactory = $algorithmManagerFactory;
56
        $this->compressionMethodManagerFactory = $compressionMethodManagerFactory;
57
        $this->headerCheckerManagerFactory = $headerCheckerManagerFactory;
58
        $this->serializerManagerFactory = $serializerManagerFactory;
59
    }
60
61
    /**
62
     * @param string[] $keyEncryptionAlgorithms
63
     * @param string[] $contentEncryptionAlgorithms
64
     * @param string[] $compressionMethods
65
     * @param string[] $headerCheckers
66
     * @param string[] $serializers
67
     *
68
     * @return JWELoader
69
     */
70
    public function create(array $keyEncryptionAlgorithms, array $contentEncryptionAlgorithms, array $compressionMethods, array $headerCheckers, array $serializers): JWELoader
71
    {
72
        $keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms);
73
        $contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithms);
74
        $compressionMethodManager = $this->compressionMethodManagerFactory->create($compressionMethods);
75
        $headerCheckerManager = $this->headerCheckerManagerFactory->create($headerCheckers);
76
        $serializerManagers = $this->serializerManagerFactory->create($serializers);
77
78
        return new JWELoader($keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager, $headerCheckerManager, $serializerManagers);
79
    }
80
}
81