Failed Conditions
Push — master ( e08481...7ad838 )
by Florent
03:52 queued 01:57
created

NestedTokenLoaderFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 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\Signature\JWSLoaderFactory;
17
18
class NestedTokenLoaderFactory
19
{
20
    /**
21
     * @var JWELoaderFactory
22
     */
23
    private $jweLoaderFactory;
24
25
    /**
26
     * @var JWSLoaderFactory
27
     */
28
    private $jwsLoaderFactory;
29
30
    /**
31
     * NestedTokenLoaderFactory constructor.
32
     *
33
     * @param JWELoaderFactory $jweLoaderFactory
34
     * @param JWSLoaderFactory $jwsLoaderFactory
35
     */
36
    public function __construct(JWELoaderFactory $jweLoaderFactory, JWSLoaderFactory $jwsLoaderFactory)
37
    {
38
        $this->jweLoaderFactory = $jweLoaderFactory;
39
        $this->jwsLoaderFactory = $jwsLoaderFactory;
40
    }
41
42
    /**
43
     * @param array $jweSerializers
44
     * @param array $keyEncryptionAlgorithms
45
     * @param array $contentEncryptionAlgorithms
46
     * @param array $compressionMethods
47
     * @param array $jweHeaderCheckers
48
     * @param array $jwsSerializers
49
     * @param array $signatureAlgorithms
50
     * @param array $jwsHeaderCheckers
51
     *
52
     * @return NestedTokenLoader
53
     */
54
    public function create(array $jweSerializers, array $keyEncryptionAlgorithms, array $contentEncryptionAlgorithms, array $compressionMethods, array $jweHeaderCheckers, array $jwsSerializers, array $signatureAlgorithms, array $jwsHeaderCheckers): NestedTokenLoader
55
    {
56
        $jweLoader = $this->jweLoaderFactory->create($jweSerializers, $keyEncryptionAlgorithms, $contentEncryptionAlgorithms, $compressionMethods, $jweHeaderCheckers);
57
        $jwsLoader = $this->jwsLoaderFactory->create($jwsSerializers, $signatureAlgorithms, $jwsHeaderCheckers);
58
59
        return new NestedTokenLoader($jweLoader, $jwsLoader);
60
    }
61
}
62