1: <?php
2:
3: namespace ShippoClient\Entity;
4:
5: use TurmericSpice\ReadableAttributes;
6:
7: class TrackingStatus
8: {
9: use ReadableAttributes {
10: mayHaveAsString as public getStatusDetails;
11: mayHaveAsString as public getStatusDate;
12: toArray as __toArray;
13: }
14:
15: 16: 17: 18: 19:
20: public function getObjectCreated()
21: {
22: return $this->attributes->mayHave('object_created')->asInstanceOf('\\DateTime');
23: }
24:
25: 26: 27: 28: 29:
30: public function getObjectUpdated()
31: {
32: return $this->attributes->mayHave('object_updated')->asInstanceOf('\\DateTime');
33: }
34:
35: 36: 37: 38: 39:
40: public function getObjectId()
41: {
42: return $this->attributes->mayHave('object_id')->asString();
43: }
44:
45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57:
58: public function getStatus()
59: {
60: return $this->attributes->mayHave('status')->asString();
61: }
62:
63: 64: 65:
66: public function getLocation()
67: {
68: $attributes = $this->attributes->mayHave('location')->asArray();
69: return new Location($attributes);
70: }
71:
72: public function toArray()
73: {
74: return [
75: 'object_created' => $this->getObjectCreated(),
76: 'object_updated' => $this->getObjectUpdated(),
77: 'object_id' => $this->getObjectId(),
78: 'status' => $this->getStatus(),
79: 'status_date' => $this->getStatusDate(),
80: 'status_details' => $this->getStatusDetails(),
81: 'location' => $this->getLocation()->toArray(),
82: ];
83: }
84: }
85: