Artifact   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 6 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\XML\Base64ElementTrait;
10
use SimpleSAML\XML\Exception\InvalidDOMElementException;
11
use SimpleSAML\XML\SchemaValidatableElementInterface;
12
use SimpleSAML\XML\SchemaValidatableElementTrait;
13
14
/**
15
 * Class for SAML artifacts.
16
 *
17
 * @package simplesamlphp/saml2
18
 */
19
final class Artifact extends AbstractSamlpElement implements SchemaValidatableElementInterface
20
{
21
    use Base64ElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\Base64ElementTrait requires some properties which are not provided by SimpleSAML\SAML2\XML\samlp\Artifact: $localName, $namespaceURI
Loading history...
22
    use SchemaValidatableElementTrait;
23
24
    /**
25
     * Initialize an artifact.
26
     *
27
     * @param string $content
28
     */
29
    public function __construct(
30
        string $content,
31
    ) {
32
        $this->setContent($content);
33
    }
34
35
36
    /**
37
     * Convert XML into an Artifact
38
     *
39
     * @param \DOMElement $xml The XML element we should load
40
     * @return static
41
     *
42
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
43
     *   If the qualified name of the supplied element is wrong
44
     */
45
    public static function fromXML(DOMElement $xml): static
46
    {
47
        Assert::same($xml->localName, 'Artifact', InvalidDOMElementException::class);
48
        Assert::same($xml->namespaceURI, Artifact::NS, InvalidDOMElementException::class);
49
50
        return new static($xml->textContent);
51
    }
52
}
53