1 | <?php |
||
50 | class Locator implements LocatorInterface |
||
51 | { |
||
52 | /** |
||
53 | * Date PCRE pattern |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | protected static $datePattern = [ |
||
58 | 'Y' => '(?P<year>\d{4})', |
||
59 | 'm' => '(?P<month>\d{2})', |
||
60 | 'd' => '(?P<day>\d{2})', |
||
61 | 'H' => '(?P<hour>\d{2})', |
||
62 | 'i' => '(?P<minute>\d{2})', |
||
63 | 's' => '(?P<second>\d{2})', |
||
64 | ]; |
||
65 | /** |
||
66 | * Creation date |
||
67 | * |
||
68 | * @var \DateTimeInterface |
||
69 | */ |
||
70 | protected $creationDate = null; |
||
71 | /** |
||
72 | * Object ID |
||
73 | * |
||
74 | * @var Id |
||
75 | */ |
||
76 | protected $uid = null; |
||
77 | /** |
||
78 | * Object type |
||
79 | * |
||
80 | * @var Type |
||
81 | */ |
||
82 | protected $type = null; |
||
83 | /** |
||
84 | * Object revision |
||
85 | * |
||
86 | * @var Revision |
||
87 | */ |
||
88 | protected $revision = null; |
||
89 | /** |
||
90 | * Hidden object |
||
91 | * |
||
92 | * @var boolean |
||
93 | */ |
||
94 | protected $hidden = false; |
||
95 | |||
96 | /******************************************************************************* |
||
97 | * PUBLIC METHODS |
||
98 | *******************************************************************************/ |
||
99 | |||
100 | /** |
||
101 | * Object URL constructor |
||
102 | * |
||
103 | * @param null|string $locator Object locator |
||
104 | * @param null|boolean|int $datePrecision Date precision [NULL = local default, TRUE = any precision (remote object |
||
105 | * URLs)] |
||
106 | * @param string $leader Leading base locator |
||
107 | * @throws InvalidArgumentException If the object URL locator is invalid |
||
108 | */ |
||
109 | 69 | public function __construct($locator = null, $datePrecision = null, &$leader = '') |
|
165 | |||
166 | /** |
||
167 | * Create and return the object URL locator |
||
168 | * |
||
169 | * @return string Object locator |
||
170 | */ |
||
171 | 40 | public function __toString() |
|
190 | |||
191 | /** |
||
192 | * Return the object's creation date |
||
193 | * |
||
194 | * @return \DateTimeInterface Object creation date |
||
195 | */ |
||
196 | 42 | public function getCreationDate() |
|
200 | |||
201 | /** |
||
202 | * Set the object's creation date |
||
203 | * |
||
204 | * @param \DateTimeInterface $creationDate |
||
205 | * @return LocatorInterface|Locator New object locator |
||
206 | */ |
||
207 | 7 | public function setCreationDate(\DateTimeInterface $creationDate) |
|
213 | |||
214 | /** |
||
215 | * Return the object type |
||
216 | * |
||
217 | * @return Type Object type |
||
218 | */ |
||
219 | 46 | public function getType() |
|
223 | |||
224 | /** |
||
225 | * Set the object type |
||
226 | * |
||
227 | * @param Type $type Object type |
||
228 | * @return LocatorInterface|Locator New object locator |
||
229 | */ |
||
230 | 7 | public function setType(Type $type) |
|
236 | |||
237 | /** |
||
238 | * Return the object ID |
||
239 | * |
||
240 | * @return Id Object ID |
||
241 | */ |
||
242 | 45 | public function getId() |
|
246 | |||
247 | /** |
||
248 | * Set the object ID |
||
249 | * |
||
250 | * @param Id $uid Object ID |
||
251 | * @return LocatorInterface|Locator New object locator |
||
252 | */ |
||
253 | 7 | public function setId(Id $uid) |
|
259 | |||
260 | /** |
||
261 | * Return the object revision |
||
262 | * |
||
263 | * @return Revision Object revision |
||
264 | */ |
||
265 | 44 | public function getRevision() |
|
269 | |||
270 | /** |
||
271 | * Set the object revision |
||
272 | * |
||
273 | * @param Revision $revision Object revision |
||
274 | * @return LocatorInterface|Locator New object locator |
||
275 | */ |
||
276 | 41 | public function setRevision(Revision $revision) |
|
282 | |||
283 | /** |
||
284 | * Return the object hidden state |
||
285 | * |
||
286 | * @return boolean Object hidden state |
||
287 | */ |
||
288 | 2 | public function isHidden() |
|
292 | |||
293 | /** |
||
294 | * Set the object hidden state |
||
295 | * |
||
296 | * @param boolean $hidden Object hidden state |
||
297 | * @return LocatorInterface|Locator New object locator |
||
298 | */ |
||
299 | 38 | public function setHidden($hidden) |
|
305 | |||
306 | /** |
||
307 | * Build the regular expression for matching a local object locator |
||
308 | * |
||
309 | * @param null|boolean|int $datePrecision Date precision [NULL = local default, TRUE = any precision (remote object |
||
310 | * URLs)] |
||
311 | * @return string Regular expression for matching a local object locator |
||
312 | * @throws InvalidArgumentException If the date precision is invalid |
||
313 | */ |
||
314 | 63 | protected function buildLocatorRegex($datePrecision) |
|
350 | } |
||
351 |