RequesterID::__construct()   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 1
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 SimpleSAML\Assert\Assert;
8
use SimpleSAML\SAML2\Exception\ArrayValidationException;
9
use SimpleSAML\SAML2\XML\URIElementTrait;
10
use SimpleSAML\XML\SchemaValidatableElementInterface;
11
use SimpleSAML\XML\SchemaValidatableElementTrait;
12
13
use function array_key_first;
14
15
/**
16
 * Class representing a samlp:RequesterID element.
17
 *
18
 * @package simplesaml/saml2
19
 */
20
final class RequesterID extends AbstractSamlpElement implements SchemaValidatableElementInterface
21
{
22
    use SchemaValidatableElementTrait;
23
    use URIElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\SAML2\XML\URIElementTrait requires some properties which are not provided by SimpleSAML\SAML2\XML\samlp\RequesterID: $localName, $namespaceURI
Loading history...
24
25
26
    /**
27
     * @param string $content
28
     */
29
    public function __construct(string $content)
30
    {
31
        $this->setContent($content);
32
    }
33
34
35
    /**
36
     * Create a class from an array
37
     *
38
     * @param array $data
39
     * @return static
40
     */
41
    public static function fromArray(array $data): static
42
    {
43
        Assert::allString($data, ArrayValidationException::class);
44
45
        $index = array_key_first($data);
46
        return new static($data[$index]);
47
    }
48
49
50
    /**
51
     * Create an array from this class
52
     *
53
     * @return array
54
     */
55
    public function toArray(): array
56
    {
57
        return [$this->getContent()];
58
    }
59
}
60