1 | <?php |
||
48 | class ObjectUrl extends Url implements LocatorInterface |
||
49 | { |
||
50 | /** |
||
51 | * Object locator |
||
52 | * |
||
53 | * @var Locator |
||
54 | */ |
||
55 | protected $locator = null; |
||
56 | |||
57 | /******************************************************************************* |
||
58 | * PUBLIC METHODS |
||
59 | *******************************************************************************/ |
||
60 | |||
61 | /** |
||
62 | * Object URL constructor |
||
63 | * |
||
64 | * @param string $url Object URL |
||
65 | * @param boolean $remote Accept remote URL (less strict date component checking) |
||
66 | * @throws InvalidArgumentException If remote URLs are not allowed and a remote URL is given |
||
67 | * @throws InvalidArgumentException If the locator component is empty |
||
68 | */ |
||
69 | 62 | public function __construct($url, $remote = false) |
|
101 | |||
102 | /** |
||
103 | * Set the object's creation date |
||
104 | * |
||
105 | * @param \DateTimeInterface $creationDate |
||
106 | * @return LocatorInterface|ObjectUrl New object locator |
||
107 | */ |
||
108 | 1 | public function setCreationDate(\DateTimeInterface $creationDate) |
|
113 | |||
114 | /** |
||
115 | * Set the object type |
||
116 | * |
||
117 | * @param Type $type Object type |
||
118 | * @return LocatorInterface|ObjectUrl New object URL |
||
119 | */ |
||
120 | 2 | public function setType(Type $type) |
|
125 | |||
126 | /** |
||
127 | * Set the object ID |
||
128 | * |
||
129 | * @param Id $uid Object ID |
||
130 | * @return LocatorInterface|ObjectUrl New object URL |
||
131 | */ |
||
132 | 1 | public function setId(Id $uid) |
|
137 | |||
138 | /** |
||
139 | * Set the object revision |
||
140 | * |
||
141 | * @param Revision $revision Object revision |
||
142 | * @return LocatorInterface|ObjectUrl New object URL |
||
143 | */ |
||
144 | 1 | public function setRevision(Revision $revision) |
|
149 | |||
150 | /** |
||
151 | * Test if this URL matches all available parts of a given URL |
||
152 | * |
||
153 | * @param Url $url Comparison URL |
||
154 | * @return bool This URL matches all available parts of the given URL |
||
155 | */ |
||
156 | 8 | public function matches(Url $url) |
|
188 | |||
189 | /** |
||
190 | * Return the object's creation date |
||
191 | * |
||
192 | * @return \DateTimeInterface Object creation date |
||
193 | */ |
||
194 | 25 | public function getCreationDate() |
|
198 | |||
199 | /** |
||
200 | * Return the object ID |
||
201 | * |
||
202 | * @return Id Object ID |
||
203 | */ |
||
204 | 25 | public function getId() |
|
208 | |||
209 | /** |
||
210 | * Return the object type |
||
211 | * |
||
212 | * @return Type Object type |
||
213 | */ |
||
214 | 27 | public function getType() |
|
218 | |||
219 | /** |
||
220 | * Return the object revision |
||
221 | * |
||
222 | * @return Revision Object revision |
||
223 | */ |
||
224 | 25 | public function getRevision() |
|
228 | |||
229 | /** |
||
230 | * Return the local object locator |
||
231 | * |
||
232 | * @return LocatorInterface|Locator Local object locator |
||
233 | */ |
||
234 | 1 | public function getLocator() |
|
238 | |||
239 | /** |
||
240 | * Return the object draft mode |
||
241 | * |
||
242 | * @return boolean Object draft mode |
||
243 | */ |
||
244 | 2 | public function isDraft() |
|
248 | |||
249 | /** |
||
250 | * Set the object draft mode |
||
251 | * |
||
252 | * @param boolean $draft Object draft mode |
||
253 | * @return LocatorInterface|ObjectUrl New object locator |
||
254 | */ |
||
255 | 1 | public function setDraft($draft) |
|
260 | |||
261 | /** |
||
262 | * Return the repository URL part of this object URL |
||
263 | * |
||
264 | * @return string Repository URL |
||
265 | * @see https://github.com/apparat/apparat/blob/master/doc/URL-DESIGN.md#repository-url |
||
266 | */ |
||
267 | 26 | public function getRepositoryUrl() |
|
287 | |||
288 | |||
289 | /** |
||
290 | * Return the object hidden state |
||
291 | * |
||
292 | * @return boolean Object hidden state |
||
293 | */ |
||
294 | 1 | public function isHidden() |
|
298 | |||
299 | /** |
||
300 | * Set the object hidden state |
||
301 | * |
||
302 | * @param boolean $hidden Object hidden state |
||
303 | * @return LocatorInterface|Locator New object locator |
||
304 | */ |
||
305 | 1 | public function setHidden($hidden) |
|
310 | |||
311 | /** |
||
312 | * Return the a complete serialized object URL |
||
313 | * |
||
314 | * @param array $override Override components |
||
315 | * @return string Serialized URL |
||
316 | */ |
||
317 | 34 | protected function getUrlInternal(array &$override = []) |
|
327 | } |
||
328 |