Passed
Pull Request — master (#358)
by Tim
03:08 queued 54s
created

Artifact::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
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\Assert\Assert;
9
use SimpleSAML\XML\Base64ElementTrait;
10
use SimpleSAML\XML\Exception\InvalidDOMElementException;
11
12
/**
13
 * Class for SAML artifacts.
14
 *
15
 * @package simplesamlphp/saml2
16
 */
17
final class Artifact extends AbstractSamlpElement
18
{
19
    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...
20
21
    /**
22
     * Initialize an artifact.
23
     *
24
     * @param string $content
25
     */
26
    public function __construct(
27
        string $content,
28
    ) {
29
        $this->setContent($content);
30
    }
31
32
33
    /**
34
     * Convert XML into an Artifact
35
     *
36
     * @param \DOMElement $xml The XML element we should load
37
     * @return static
38
     *
39
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
40
     *   If the qualified name of the supplied element is wrong
41
     */
42
    public static function fromXML(DOMElement $xml): static
43
    {
44
        Assert::same($xml->localName, 'Artifact', InvalidDOMElementException::class);
45
        Assert::same($xml->namespaceURI, Artifact::NS, InvalidDOMElementException::class);
46
47
        return new static($xml->textContent);
48
    }
49
}
50