1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Ssdp project. |
4
|
|
|
* |
5
|
|
|
* @author Daniel Schröder <[email protected]> |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace GravityMedia\Ssdp; |
9
|
|
|
|
10
|
|
|
use Ramsey\Uuid\UuidInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Abstract identifier class |
14
|
|
|
* |
15
|
|
|
* @package GravityMedia\Ssdp |
16
|
|
|
*/ |
17
|
|
|
abstract class AbstractIdentifier |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var UuidInterface |
21
|
|
|
*/ |
22
|
|
|
protected $id; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var boolean |
26
|
|
|
*/ |
27
|
|
|
protected $rootDevice; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var boolean |
31
|
|
|
*/ |
32
|
|
|
protected $device; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var boolean; |
36
|
|
|
*/ |
37
|
|
|
protected $service; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $domainName; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $type; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var int |
51
|
|
|
*/ |
52
|
|
|
protected $version; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get id |
56
|
|
|
* |
57
|
|
|
* @return null|UuidInterface |
58
|
|
|
*/ |
59
|
|
|
public function getId() |
60
|
|
|
{ |
61
|
|
|
return $this->id; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Set id |
66
|
|
|
* |
67
|
|
|
* @param UuidInterface $id |
68
|
|
|
* |
69
|
|
|
* @return $this |
70
|
|
|
*/ |
71
|
|
|
public function setId(UuidInterface $id) |
72
|
|
|
{ |
73
|
|
|
$this->id = $id; |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Return whether this is a root device |
79
|
|
|
* |
80
|
|
|
* @return boolean |
81
|
|
|
*/ |
82
|
|
|
public function isRootDevice() |
83
|
|
|
{ |
84
|
|
|
if (null === $this->rootDevice) { |
85
|
|
|
return false; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return $this->rootDevice; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Set root device |
93
|
|
|
* |
94
|
|
|
* @param boolean $rootDevice |
95
|
|
|
* |
96
|
|
|
* @return $this |
97
|
|
|
*/ |
98
|
|
|
public function setRootDevice($rootDevice) |
99
|
|
|
{ |
100
|
|
|
$this->rootDevice = $rootDevice; |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Return whether this is a device |
106
|
|
|
* |
107
|
|
|
* @return boolean |
108
|
|
|
*/ |
109
|
|
|
public function isDevice() |
110
|
|
|
{ |
111
|
|
|
return $this->device; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Set device |
116
|
|
|
* |
117
|
|
|
* @param boolean $device |
118
|
|
|
* |
119
|
|
|
* @return $this |
120
|
|
|
*/ |
121
|
|
|
public function setDevice($device) |
122
|
|
|
{ |
123
|
|
|
$this->device = $device; |
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Return whether this is a service |
129
|
|
|
* |
130
|
|
|
* @return boolean |
131
|
|
|
*/ |
132
|
|
|
public function isService() |
133
|
|
|
{ |
134
|
|
|
return $this->service; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Set service |
139
|
|
|
* |
140
|
|
|
* @param boolean $service |
141
|
|
|
* |
142
|
|
|
* @return $this |
143
|
|
|
*/ |
144
|
|
|
public function setService($service) |
145
|
|
|
{ |
146
|
|
|
$this->service = $service; |
147
|
|
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Get domainName |
152
|
|
|
* |
153
|
|
|
* @return string |
154
|
|
|
*/ |
155
|
|
|
public function getDomainName() |
156
|
|
|
{ |
157
|
|
|
if (null === $this->domainName) { |
158
|
|
|
return 'schemas-upnp-org'; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
return $this->domainName; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Set domainName |
166
|
|
|
* |
167
|
|
|
* @param string $domainName |
168
|
|
|
* |
169
|
|
|
* @return $this |
170
|
|
|
*/ |
171
|
|
|
public function setDomainName($domainName) |
172
|
|
|
{ |
173
|
|
|
$this->domainName = $domainName; |
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Get type |
179
|
|
|
* |
180
|
|
|
* @return string |
181
|
|
|
*/ |
182
|
|
|
public function getType() |
183
|
|
|
{ |
184
|
|
|
if (null === $this->type) { |
185
|
|
|
return 'Basic'; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
return $this->type; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Set type |
193
|
|
|
* |
194
|
|
|
* @param string $type |
195
|
|
|
* |
196
|
|
|
* @return $this |
197
|
|
|
*/ |
198
|
|
|
public function setType($type) |
199
|
|
|
{ |
200
|
|
|
$this->type = $type; |
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Get version |
206
|
|
|
* |
207
|
|
|
* @return int |
208
|
|
|
*/ |
209
|
|
|
public function getVersion() |
210
|
|
|
{ |
211
|
|
|
if (null === $this->version) { |
212
|
|
|
return 1; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
return $this->version; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Set version |
220
|
|
|
* |
221
|
|
|
* @param int $version |
222
|
|
|
* |
223
|
|
|
* @return $this |
224
|
|
|
*/ |
225
|
|
|
public function setVersion($version) |
226
|
|
|
{ |
227
|
|
|
$this->version = $version; |
228
|
|
|
return $this; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Return this object as a string when the object is used in any string context. |
233
|
|
|
* |
234
|
|
|
* @return string |
235
|
|
|
*/ |
236
|
|
|
public function __toString() |
237
|
|
|
{ |
238
|
|
|
return $this->toString(); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Return this sobject as a string. |
243
|
|
|
* |
244
|
|
|
* @return string |
245
|
|
|
*/ |
246
|
|
|
abstract public function toString(); |
247
|
|
|
} |
248
|
|
|
|