|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\XML\md; |
|
6
|
|
|
|
|
7
|
|
|
use SimpleSAML\SAML2\Assert\Assert; |
|
8
|
|
|
use SimpleSAML\SAML2\Exception\ArrayValidationException; |
|
9
|
|
|
use SimpleSAML\SAML2\Type\SAMLStringValue; |
|
10
|
|
|
use SimpleSAML\XML\ArrayizableElementInterface; |
|
11
|
|
|
use SimpleSAML\XML\SchemaValidatableElementInterface; |
|
12
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
|
13
|
|
|
use SimpleSAML\XML\TypedTextContentTrait; |
|
14
|
|
|
|
|
15
|
|
|
use function array_key_first; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class implementing TelephoneNumber. |
|
19
|
|
|
* |
|
20
|
|
|
* @package simplesamlphp/saml2 |
|
21
|
|
|
*/ |
|
22
|
|
|
final class TelephoneNumber extends AbstractMdElement implements |
|
23
|
|
|
ArrayizableElementInterface, |
|
24
|
|
|
SchemaValidatableElementInterface |
|
25
|
|
|
{ |
|
26
|
|
|
use SchemaValidatableElementTrait; |
|
27
|
|
|
use TypedTextContentTrait; |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
public const string TEXTCONTENT_TYPE = SAMLStringValue::class; |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Create a class from an array |
|
35
|
|
|
* |
|
36
|
|
|
* @param array<string> $data |
|
37
|
|
|
*/ |
|
38
|
|
|
public static function fromArray(array $data): static |
|
39
|
|
|
{ |
|
40
|
|
|
Assert::allString($data, ArrayValidationException::class); |
|
41
|
|
|
|
|
42
|
|
|
$index = array_key_first($data); |
|
43
|
|
|
return new static( |
|
44
|
|
|
SAMLStringValue::fromString($data[$index]), |
|
45
|
|
|
); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Create an array from this class |
|
51
|
|
|
* |
|
52
|
|
|
* @return array<string> |
|
53
|
|
|
*/ |
|
54
|
|
|
public function toArray(): array |
|
55
|
|
|
{ |
|
56
|
|
|
return [$this->getContent()->getValue()]; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|