Passed
Push — master ( 8447f6...77de30 )
by Tim
01:32
created

AbstractNameIDMappingRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 8
dl 0
loc 13
rs 10

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\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
9
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\Type\SAMLDateTimeValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use SimpleSAML\SAML2\XML\IdentifierTrait;
11
use SimpleSAML\SAML2\XML\saml\IdentifierInterface;
12
use SimpleSAML\SAML2\XML\saml\Issuer;
13
use SimpleSAML\SAML2\XML\samlp\NameIDPolicy;
14
use SimpleSAML\XMLSchema\Type\IDValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\IDValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * Class representing the samlp:NameIDMappingRequestType.
18
 *
19
 * @package simplesamlphp/saml2
20
 */
21
abstract class AbstractNameIDMappingRequest extends AbstractRequest
22
{
23
    use IdentifierTrait;
24
25
26
    /**
27
     * Initialize a NameIDMappingRequest.
28
     *
29
     * @param \SimpleSAML\SAML2\XML\saml\IdentifierInterface $identifier
30
     * @param \SimpleSAML\SAML2\XML\samlp\NameIDPolicy $nameIdPolicy
31
     * @param \SimpleSAML\XMLSchema\Type\IDValue $id
32
     * @param \SimpleSAML\SAML2\XML\saml\Issuer|null $issuer
33
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $issueInstant
34
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $destination
35
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $consent
36
     * @param \SimpleSAML\SAML2\XML\samlp\Extensions $extensions
37
     */
38
    final public function __construct(
39
        IdentifierInterface $identifier,
40
        protected NameIDPolicy $nameIdPolicy,
41
        IDValue $id,
42
        ?Issuer $issuer = null,
43
        ?SAMLDateTimeValue $issueInstant = null,
44
        ?SAMLAnyURIValue $destination = null,
45
        ?SAMLAnyURIValue $consent = null,
46
        ?Extensions $extensions = null,
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\XML\samlp\Extensions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
47
    ) {
48
        $this->setIdentifier($identifier);
49
50
        parent::__construct($id, $issuer, $issueInstant, $destination, $consent, $extensions);
51
    }
52
53
54
    /**
55
     * Retrieve the NameIDPolicy of this element.
56
     *
57
     * @return \SimpleSAML\SAML2\XML\samlp\NameIDPolicy
58
     */
59
    public function getNameIDPolicy(): NameIDPolicy
60
    {
61
        return $this->nameIdPolicy;
62
    }
63
64
65
    /**
66
     * Convert this NameIDMappingRequest to XML
67
     */
68
    public function toUnsignedXML(?DOMElement $parent = null): DOMElement
69
    {
70
        $e = parent::toUnsignedXML($parent);
71
72
        $this->getIdentifier()->toXML($e);
0 ignored issues
show
Bug introduced by
The method toXML() does not exist on SimpleSAML\SAML2\XML\saml\IdentifierInterface. It seems like you code against a sub-type of said class. However, the method does not exist in SimpleSAML\SAML2\XML\saml\BaseIdentifierInterface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

72
        $this->getIdentifier()->/** @scrutinizer ignore-call */ toXML($e);
Loading history...
73
        $this->getNameIDPolicy()->toXML($e);
74
75
        return $e;
76
    }
77
}
78