|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OpenConext\Value\Saml\Metadata\ContactPerson; |
|
4
|
|
|
|
|
5
|
|
|
use OpenConext\Value\Exception\InvalidArgumentException; |
|
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
|
|
|
if (!in_array($type, self::$validTypes)) { |
|
34
|
|
|
$validMessage = 'one of "ContactType::' . implode(', ContactType::', self::$validTypes) . '"'; |
|
35
|
|
|
throw InvalidArgumentException::invalidType($validMessage, 'type', $type); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$this->type = $type; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return ContactType |
|
43
|
|
|
*/ |
|
44
|
|
|
public static function administrative() |
|
45
|
|
|
{ |
|
46
|
|
|
return new self(self::TYPE_ADMINISTRATIVE); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return ContactType |
|
51
|
|
|
*/ |
|
52
|
|
|
public static function billing() |
|
53
|
|
|
{ |
|
54
|
|
|
return new self(self::TYPE_BILLING); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return ContactType |
|
59
|
|
|
*/ |
|
60
|
|
|
public static function other() |
|
61
|
|
|
{ |
|
62
|
|
|
return new self(self::TYPE_OTHER); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return ContactType |
|
67
|
|
|
*/ |
|
68
|
|
|
public static function support() |
|
69
|
|
|
{ |
|
70
|
|
|
return new self(self::TYPE_SUPPORT); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return ContactType |
|
75
|
|
|
*/ |
|
76
|
|
|
public static function technical() |
|
77
|
|
|
{ |
|
78
|
|
|
return new self(self::TYPE_TECHNICAL); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return string |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getType() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->type; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param ContactType $other |
|
91
|
|
|
* @return bool |
|
92
|
|
|
*/ |
|
93
|
|
|
public function equals(ContactType $other) |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->type === $other->type; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function __toString() |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->type; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|