1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the LightSAML-Core package. |
5
|
|
|
* |
6
|
|
|
* (c) Milos Tomic <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace LightSaml\Model\Metadata; |
13
|
|
|
|
14
|
|
|
use LightSaml\Model\Context\DeserializationContext; |
15
|
|
|
use LightSaml\Model\Context\SerializationContext; |
16
|
|
|
use LightSaml\Model\AbstractSamlModel; |
17
|
|
|
use LightSaml\SamlConstants; |
18
|
|
|
|
19
|
|
|
class ContactPerson extends AbstractSamlModel |
20
|
|
|
{ |
21
|
|
|
const TYPE_TECHNICAL = 'technical'; |
22
|
|
|
const TYPE_SUPPORT = 'support'; |
23
|
|
|
const TYPE_ADMINISTRATIVE = 'administrative'; |
24
|
|
|
const TYPE_BILLING = 'billing'; |
25
|
|
|
const TYPE_OTHER = 'other'; |
26
|
|
|
|
27
|
|
|
/** @var string */ |
28
|
|
|
protected $contactType; |
29
|
|
|
|
30
|
|
|
/** @var string|null */ |
31
|
|
|
protected $company; |
32
|
|
|
|
33
|
|
|
/** @var string|null */ |
34
|
|
|
protected $givenName; |
35
|
|
|
|
36
|
|
|
/** @var string|null */ |
37
|
|
|
protected $surName; |
38
|
|
|
|
39
|
|
|
/** @var string|null */ |
40
|
|
|
protected $emailAddress; |
41
|
|
|
|
42
|
|
|
/** @var string|null */ |
43
|
|
|
protected $telephoneNumber; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $contactType |
47
|
|
|
* |
48
|
|
|
* @return ContactPerson |
49
|
|
|
*/ |
50
|
34 |
|
public function setContactType($contactType) |
51
|
|
|
{ |
52
|
34 |
|
$this->contactType = (string) $contactType; |
53
|
|
|
|
54
|
34 |
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
3 |
|
public function getContactType() |
61
|
|
|
{ |
62
|
3 |
|
return $this->contactType; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param null|string $company |
67
|
|
|
* |
68
|
|
|
* @return ContactPerson |
69
|
|
|
*/ |
70
|
1 |
|
public function setCompany($company) |
71
|
|
|
{ |
72
|
1 |
|
$this->company = $company; |
73
|
|
|
|
74
|
1 |
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return null|string |
79
|
|
|
*/ |
80
|
3 |
|
public function getCompany() |
81
|
|
|
{ |
82
|
3 |
|
return $this->company; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param null|string $emailAddress |
87
|
|
|
* |
88
|
|
|
* @return ContactPerson |
89
|
|
|
*/ |
90
|
14 |
|
public function setEmailAddress($emailAddress) |
91
|
|
|
{ |
92
|
14 |
|
$this->emailAddress = $emailAddress; |
93
|
|
|
|
94
|
14 |
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return null|string |
99
|
|
|
*/ |
100
|
3 |
|
public function getEmailAddress() |
101
|
|
|
{ |
102
|
3 |
|
return $this->emailAddress; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param null|string $givenName |
107
|
|
|
* |
108
|
|
|
* @return ContactPerson |
109
|
|
|
*/ |
110
|
13 |
|
public function setGivenName($givenName) |
111
|
|
|
{ |
112
|
13 |
|
$this->givenName = $givenName; |
113
|
|
|
|
114
|
13 |
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return null|string |
119
|
|
|
*/ |
120
|
3 |
|
public function getGivenName() |
121
|
|
|
{ |
122
|
3 |
|
return $this->givenName; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param null|string $surName |
127
|
|
|
* |
128
|
|
|
* @return ContactPerson |
129
|
|
|
*/ |
130
|
12 |
|
public function setSurName($surName) |
131
|
|
|
{ |
132
|
12 |
|
$this->surName = $surName; |
133
|
|
|
|
134
|
12 |
|
return $this; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return null|string |
139
|
|
|
*/ |
140
|
3 |
|
public function getSurName() |
141
|
|
|
{ |
142
|
3 |
|
return $this->surName; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param null|string $telephoneNumber |
147
|
|
|
* |
148
|
|
|
* @return ContactPerson |
149
|
|
|
*/ |
150
|
1 |
|
public function setTelephoneNumber($telephoneNumber) |
151
|
|
|
{ |
152
|
1 |
|
$this->telephoneNumber = $telephoneNumber; |
153
|
|
|
|
154
|
1 |
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @return null|string |
159
|
|
|
*/ |
160
|
3 |
|
public function getTelephoneNumber() |
161
|
|
|
{ |
162
|
3 |
|
return $this->telephoneNumber; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param \DOMNode $parent |
167
|
|
|
* @param SerializationContext $context |
168
|
|
|
* |
169
|
|
|
* @return void |
170
|
|
|
*/ |
171
|
2 |
View Code Duplication |
public function serialize(\DOMNode $parent, SerializationContext $context) |
|
|
|
|
172
|
|
|
{ |
173
|
2 |
|
$result = $this->createElement('ContactPerson', SamlConstants::NS_METADATA, $parent, $context); |
174
|
|
|
|
175
|
2 |
|
$this->attributesToXml(array('contactType'), $result); |
176
|
|
|
|
177
|
2 |
|
$this->singleElementsToXml( |
178
|
2 |
|
array('Company', 'GivenName', 'SurName', 'EmailAddress', 'TelephoneNumber'), |
179
|
2 |
|
$result, |
180
|
2 |
|
$context, |
181
|
2 |
|
SamlConstants::NS_METADATA |
182
|
|
|
); |
183
|
2 |
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param \DOMNode $node |
187
|
|
|
* @param DeserializationContext $context |
188
|
|
|
*/ |
189
|
32 |
|
public function deserialize(\DOMNode $node, DeserializationContext $context) |
190
|
|
|
{ |
191
|
32 |
|
$this->checkXmlNodeName($node, 'ContactPerson', SamlConstants::NS_METADATA); |
192
|
|
|
|
193
|
32 |
|
$this->attributesFromXml($node, array('contactType')); |
|
|
|
|
194
|
|
|
|
195
|
32 |
|
$this->singleElementsFromXml($node, $context, array( |
|
|
|
|
196
|
32 |
|
'Company' => array('md', null), |
197
|
|
|
'GivenName' => array('md', null), |
198
|
|
|
'SurName' => array('md', null), |
199
|
|
|
'EmailAddress' => array('md', null), |
200
|
|
|
'TelephoneNumber' => array('md', null), |
201
|
|
|
)); |
202
|
32 |
|
} |
203
|
|
|
} |
204
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.