|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OpenConext\Value\Saml\Metadata\ContactPerson; |
|
4
|
|
|
|
|
5
|
|
|
use OpenConext\Value\Assert\Assertion; |
|
6
|
|
|
use OpenConext\Value\Serializable; |
|
7
|
|
|
|
|
8
|
|
|
final class ContactType implements Serializable |
|
9
|
|
|
{ |
|
10
|
|
|
const TYPE_ADMINISTRATIVE = 'administrative'; |
|
11
|
|
|
const TYPE_BILLING = 'billing'; |
|
12
|
|
|
const TYPE_OTHER = 'other'; |
|
13
|
|
|
const TYPE_SUPPORT = 'support'; |
|
14
|
|
|
const TYPE_TECHNICAL = 'technical'; |
|
15
|
|
|
|
|
16
|
|
|
private static $validTypes = array( |
|
17
|
|
|
self::TYPE_ADMINISTRATIVE, |
|
18
|
|
|
self::TYPE_BILLING, |
|
19
|
|
|
self::TYPE_OTHER, |
|
20
|
|
|
self::TYPE_SUPPORT, |
|
21
|
|
|
self::TYPE_TECHNICAL |
|
22
|
|
|
); |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $contactType; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
** @param string $type one of the ContactType::TYPE_* constants |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct($type) |
|
33
|
|
|
{ |
|
34
|
|
|
$validMessage = 'one of "ContactType::' . implode(', ContactType::', self::$validTypes) . '"'; |
|
35
|
|
|
Assertion::inArray($type, self::$validTypes, $validMessage); |
|
36
|
|
|
|
|
37
|
|
|
$this->contactType = $type; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @return ContactType |
|
42
|
|
|
*/ |
|
43
|
|
|
public static function administrative() |
|
44
|
|
|
{ |
|
45
|
|
|
return new self(self::TYPE_ADMINISTRATIVE); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @return ContactType |
|
50
|
|
|
*/ |
|
51
|
|
|
public static function billing() |
|
52
|
|
|
{ |
|
53
|
|
|
return new self(self::TYPE_BILLING); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return ContactType |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function other() |
|
60
|
|
|
{ |
|
61
|
|
|
return new self(self::TYPE_OTHER); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return ContactType |
|
66
|
|
|
*/ |
|
67
|
|
|
public static function support() |
|
68
|
|
|
{ |
|
69
|
|
|
return new self(self::TYPE_SUPPORT); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return ContactType |
|
74
|
|
|
*/ |
|
75
|
|
|
public static function technical() |
|
76
|
|
|
{ |
|
77
|
|
|
return new self(self::TYPE_TECHNICAL); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @return string |
|
82
|
|
|
*/ |
|
83
|
|
|
public function getContactType() |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->contactType; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @param ContactType $other |
|
90
|
|
|
* @return bool |
|
91
|
|
|
*/ |
|
92
|
|
|
public function equals(ContactType $other) |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->contactType === $other->contactType; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public static function deserialize($data) |
|
98
|
|
|
{ |
|
99
|
|
|
return new self($data); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function serialize() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->contactType; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function __toString() |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->contactType; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|