Passed
Push — master ( 92085d...93354f )
by Tim
02:29
created

TelephoneNumber::validateContent()   A

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