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