Passed
Push — master ( f3e803...79c4ca )
by Tim
02:20
created

ServiceProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 10
dl 0
loc 24
rs 9.9

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
namespace SimpleSAML\SAML2\Metadata;
6
7
use SimpleSAML\Assert\Assert;
8
use SimpleSAML\SAML2\XML\md\AssertionConsumerService;
9
use SimpleSAML\XMLSecurity\Constants as C;
10
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmFactory;
11
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
12
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
13
use SimpleSAML\XMLSecurity\Key\{PrivateKey, PublicKey, SymmetricKey};
14
15
/**
16
 * Class holding configuration for a SAML 2 Service Provider.
17
 *
18
 * @package simplesamlphp/saml2
19
 */
20
class ServiceProvider extends AbstractProvider
21
{
22
    /**
23
     */
24
    public function __construct(
25
        string $entityId,
26
        EncryptionAlgorithmFactory|KeyTransportAlgorithmFactory|null $encryptionAlgorithmFactory = null,
27
        SignatureAlgorithmFactory|null $signatureAlgorithmFactory = null,
28
        string $signatureAlgorithm = C::SIG_RSA_SHA256,
29
        array $validatingKeys = [],
30
        PrivateKey|null $signingKey = null,
31
        PublicKey|SymmetricKey|null $encryptionKey = null,
32
        protected array $assertionConsumerService = [],
33
        array $decryptionKeys = [],
34
        array $IDPList = [],
35
    ) {
36
        Assert::allIsInstanceOf($assertionConsumerService, AssertionConsumerService::class);
37
38
        parent::__construct(
39
            $entityId,
40
            $encryptionAlgorithmFactory,
41
            $signatureAlgorithmFactory,
42
            $signatureAlgorithm,
43
            $validatingKeys,
44
            $signingKey,
45
            $encryptionKey,
46
            $decryptionKeys,
47
            $IDPList,
48
        );
49
    }
50
51
52
    /**
53
     * Retrieve the configured ACS-endpoints for this Service Provider.
54
     *
55
     * @return array<\SimpleSAML\SAML2\XML\md\AssertionConsumerService>
56
     */
57
    public function getAssertionConsumerService(): array
58
    {
59
        return $this->assertionConsumerService;
60
    }
61
}
62