AbstractStatusResponse::getInResponseTo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Constants as C;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\Constants 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...
9
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
10
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...
11
use SimpleSAML\SAML2\XML\saml\Issuer;
12
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...
13
use SimpleSAML\XMLSchema\Type\NCNameValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\NCNameValue 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...
14
15
/**
16
 * Base class for all SAML 2 response messages.
17
 *
18
 * Implements samlp:StatusResponseType. All of the elements in that type are
19
 * stored in the \SimpleSAML\SAML2\XML\AbstractMessage class, and this class is therefore more
20
 * or less empty. It is included mainly to make it easy to separate requests from
21
 * responses.
22
 *
23
 * @package simplesamlphp/saml2
24
 */
25
abstract class AbstractStatusResponse extends AbstractMessage
26
{
27
    /**
28
     * Constructor for SAML 2 response messages.
29
     *
30
     * @param \SimpleSAML\XMLSchema\Type\IDValue $id
31
     * @param \SimpleSAML\SAML2\XML\samlp\Status $status
32
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue $issueInstant
33
     * @param \SimpleSAML\SAML2\XML\saml\Issuer|null $issuer
34
     * @param \SimpleSAML\XMLSchema\Type\NCNameValue|null $inResponseTo
35
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $destination
36
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $consent
37
     * @param \SimpleSAML\SAML2\XML\samlp\Extensions|null $extensions
38
     *
39
     * @throws \Exception
40
     */
41
    protected function __construct(
42
        IDValue $id,
43
        protected Status $status,
44
        SAMLDateTimeValue $issueInstant,
45
        ?Issuer $issuer = null,
46
        protected ?NCNameValue $inResponseTo = null,
47
        ?SAMLAnyURIValue $destination = null,
48
        ?SAMLAnyURIValue $consent = null,
49
        ?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...
50
    ) {
51
        parent::__construct($id, $issuer, $issueInstant, $destination, $consent, $extensions);
52
    }
53
54
55
    /**
56
     * Determine whether this is a successful response.
57
     *
58
     * @return bool true if the status code is success, false if not.
59
     */
60
    public function isSuccess(): bool
61
    {
62
        return strval($this->status->getStatusCode()->getValue()) === C::STATUS_SUCCESS;
63
    }
64
65
66
    /**
67
     * Retrieve the ID of the request this is a response to.
68
     *
69
     * @return \SimpleSAML\XMLSchema\Type\NCNameValue|null The ID of the request.
70
     */
71
    public function getInResponseTo(): ?NCNameValue
72
    {
73
        return $this->inResponseTo;
74
    }
75
76
77
    /**
78
     * Retrieve the status code.
79
     *
80
     * @return \SimpleSAML\SAML2\XML\samlp\Status The status code.
81
     */
82
    public function getStatus(): Status
83
    {
84
        return $this->status;
85
    }
86
87
88
    /**
89
     * Convert this message to an unsigned XML document.
90
     * This method does not sign the resulting XML document.
91
     */
92
    protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
93
    {
94
        $e = parent::toUnsignedXML($parent);
95
96
        if ($this->getInResponseTo() !== null) {
97
            $e->setAttribute('InResponseTo', $this->getInResponseTo()->getValue());
98
        }
99
100
        $this->getStatus()->toXML($e);
101
102
        return $e;
103
    }
104
}
105