AuthenticationSuccess   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 19
c 0
b 0
f 0
dl 0
loc 42
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 29 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\CAS\XML;
6
7
use DOMElement;
8
use SimpleSAML\CAS\Assert\Assert;
9
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
10
use SimpleSAML\XMLSchema\Exception\MissingElementException;
11
12
use function array_pop;
13
14
/**
15
 * Class for CAS authenticationSuccess
16
 *
17
 * @package simplesamlphp/xml-cas
18
 */
19
final class AuthenticationSuccess extends AbstractAuthenticationSuccess
0 ignored issues
show
Bug introduced by
The type SimpleSAML\CAS\XML\AbstractAuthenticationSuccess 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...
20
{
21
    /**
22
     * Convert XML into a cas:authenticationSuccess-element
23
     *
24
     * @param \DOMElement $xml The XML element we should load
25
     * @return static
26
     *
27
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
28
     *   if the qualified name of the supplied element is wrong
29
     * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
30
     *   if the supplied element is missing one of the mandatory attributes
31
     */
32
    public static function fromXML(DOMElement $xml): static
33
    {
34
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
35
        Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class);
36
37
        $user = User::getChildrenOfClass($xml);
0 ignored issues
show
Bug introduced by
The type SimpleSAML\CAS\XML\User 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...
38
        Assert::count(
39
            $user,
40
            1,
41
            'Exactly one <cas:user> must be specified.',
42
            MissingElementException::class,
43
        );
44
45
        $attributes = Attributes::getChildrenOfClass($xml);
46
        Assert::count(
47
            $attributes,
48
            1,
49
            'Exactly one <cas:attributes> must be specified.',
50
            MissingElementException::class,
51
        );
52
53
        $proxyGrantingTicket = ProxyGrantingTicket::getChildrenOfClass($xml);
0 ignored issues
show
Bug introduced by
The type SimpleSAML\CAS\XML\ProxyGrantingTicket 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...
54
        $proxies = Proxies::getChildrenOfClass($xml);
55
56
        return new static(
57
            $user[0],
58
            $attributes[0],
59
            array_pop($proxyGrantingTicket),
60
            array_pop($proxies),
61
        );
62
    }
63
}
64