1 | <?php |
||
56 | abstract class AbstractObject implements ObjectInterface |
||
57 | { |
||
58 | /** |
||
59 | * System properties |
||
60 | * |
||
61 | * @var SystemProperties |
||
62 | */ |
||
63 | protected $systemProperties; |
||
64 | /** |
||
65 | * Meta properties |
||
66 | * |
||
67 | * @var MetaProperties |
||
68 | */ |
||
69 | protected $metaProperties; |
||
70 | /** |
||
71 | * Domain properties |
||
72 | * |
||
73 | * @var AbstractDomainProperties |
||
74 | */ |
||
75 | protected $domainProperties; |
||
76 | /** |
||
77 | * Object payload |
||
78 | * |
||
79 | * @var string |
||
80 | */ |
||
81 | protected $payload; |
||
82 | /** |
||
83 | * Repository path |
||
84 | * |
||
85 | * @var RepositoryPathInterface |
||
86 | */ |
||
87 | protected $path; |
||
88 | /** |
||
89 | * Domain property collection class |
||
90 | * |
||
91 | * @var string |
||
92 | */ |
||
93 | protected $domainPropertyCClass = AbstractDomainProperties::class; |
||
94 | /** |
||
95 | * Object relations |
||
96 | * |
||
97 | * @var Relations |
||
98 | */ |
||
99 | protected $relations; |
||
100 | /** |
||
101 | * Processing instructions |
||
102 | * |
||
103 | * @var ProcessingInstructions |
||
104 | */ |
||
105 | protected $processingInstructions; |
||
106 | /** |
||
107 | * Latest revision index |
||
108 | * |
||
109 | * @var Revision |
||
110 | */ |
||
111 | protected $latestRevision; |
||
112 | |||
113 | /** |
||
114 | * Object constructor |
||
115 | * |
||
116 | * @param string $payload Object payload |
||
117 | * @param array $propertyData Property data |
||
118 | * @param RepositoryPathInterface $path Object repository path |
||
119 | */ |
||
120 | 18 | public function __construct($payload = '', array $propertyData = [], RepositoryPathInterface $path = null) |
|
145 | |||
146 | /** |
||
147 | * Load object revision data |
||
148 | * |
||
149 | * @param string $payload Object payload |
||
150 | * @param array $propertyData Property data |
||
151 | */ |
||
152 | 17 | protected function loadRevisionData($payload = '', array $propertyData = []) |
|
191 | |||
192 | /** |
||
193 | * Return the object revision |
||
194 | * |
||
195 | * @return Revision Object revision |
||
196 | */ |
||
197 | 15 | public function getRevision() |
|
201 | |||
202 | /** |
||
203 | * Use a specific object revision |
||
204 | * |
||
205 | * @param Revision $revision Revision to be used |
||
206 | * @return ObjectInterface Object |
||
207 | * @throws OutOfBoundsException If the requested revision is invalid |
||
208 | */ |
||
209 | public function useRevision(Revision $revision) |
||
237 | |||
238 | /** |
||
239 | * Return the object ID |
||
240 | * |
||
241 | * @return Id Object ID |
||
242 | */ |
||
243 | 5 | public function getId() |
|
247 | |||
248 | /** |
||
249 | * Return the object type |
||
250 | * |
||
251 | * @return Type Object type |
||
252 | */ |
||
253 | 1 | public function getType() |
|
257 | |||
258 | /** |
||
259 | * Return the creation date & time |
||
260 | * |
||
261 | * @return \DateTimeImmutable Creation date & time |
||
262 | */ |
||
263 | 1 | public function getCreated() |
|
267 | |||
268 | /** |
||
269 | * Return the publication date & time |
||
270 | * |
||
271 | * @return \DateTimeImmutable Publication date & time |
||
272 | */ |
||
273 | 1 | public function getPublished() |
|
277 | |||
278 | /** |
||
279 | * Return the object hash |
||
280 | * |
||
281 | * @return string Object hash |
||
282 | */ |
||
283 | 1 | public function getHash() |
|
287 | |||
288 | /** |
||
289 | * Return the object description |
||
290 | * |
||
291 | * @return string Object description |
||
292 | */ |
||
293 | 1 | public function getDescription() |
|
297 | |||
298 | /** |
||
299 | * Return the object abstract |
||
300 | * |
||
301 | * @return string Object abstract |
||
302 | */ |
||
303 | 1 | public function getAbstract() |
|
307 | |||
308 | /** |
||
309 | * Return all object keywords |
||
310 | * |
||
311 | * @return array Object keywords |
||
312 | */ |
||
313 | 1 | public function getKeywords() |
|
317 | |||
318 | /** |
||
319 | * Return all object categories |
||
320 | * |
||
321 | * @return array Object categories |
||
322 | */ |
||
323 | 1 | public function getCategories() |
|
327 | |||
328 | /** |
||
329 | * Return all object authors |
||
330 | * |
||
331 | * @return AuthorInterface[] Authors |
||
332 | */ |
||
333 | 2 | public function getAuthors() |
|
337 | |||
338 | /** |
||
339 | * Add an object author |
||
340 | * |
||
341 | * @param AuthorInterface $author Author |
||
342 | * @return ObjectInterface Self reference |
||
343 | */ |
||
344 | 1 | public function addAuthor(AuthorInterface $author) |
|
351 | |||
352 | /** |
||
353 | * Return the object repository path |
||
354 | * |
||
355 | * @return RepositoryPathInterface Object repository path |
||
356 | */ |
||
357 | 15 | public function getRepositoryPath() |
|
361 | |||
362 | /** |
||
363 | * Return the object property data |
||
364 | * |
||
365 | * @return array Object property data |
||
366 | */ |
||
367 | 2 | public function getPropertyData() |
|
381 | |||
382 | /** |
||
383 | * Return the object payload |
||
384 | * |
||
385 | * @return string Object payload |
||
386 | */ |
||
387 | 2 | public function getPayload() |
|
391 | |||
392 | /** |
||
393 | * Return the absolute object URL |
||
394 | * |
||
395 | * @return string |
||
396 | */ |
||
397 | 1 | public function getAbsoluteUrl() |
|
401 | |||
402 | /** |
||
403 | * Get a particular property value |
||
404 | * |
||
405 | * Multi-level properties might be traversed by property name paths separated with colons (":"). |
||
406 | * |
||
407 | * @param string $property Property name |
||
408 | * @return mixed Property value |
||
409 | */ |
||
410 | 2 | public function getDomainProperty($property) |
|
414 | } |
||
415 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: