1 | <?php |
||
7 | class Tracks |
||
8 | { |
||
9 | use ReadableAttributes { |
||
10 | mayHaveAsString as public getCarrier; |
||
11 | mayHaveAsString as public getTrackingNumber; |
||
12 | mayHaveAsString as public getEta; |
||
13 | toArray as public __toArray; |
||
14 | } |
||
15 | |||
16 | /** |
||
17 | * @return \ShippoClient\Entity\TrackingStatus |
||
18 | */ |
||
19 | public function getTrackingStatus() |
||
20 | { |
||
21 | return new TrackingStatus($this->attributes->mayHave('tracking_status')->asArray()); |
||
|
|||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @return \ShippoClient\Entity\TrackingHistory |
||
26 | */ |
||
27 | public function getTrackingHistory() |
||
34 | |||
35 | /** |
||
36 | * @return \ShippoClient\Entity\Location |
||
37 | */ |
||
38 | public function getAddressFrom() |
||
44 | |||
45 | /** |
||
46 | * @return \ShippoClient\Entity\Location |
||
47 | */ |
||
48 | public function getAddressTo() |
||
54 | |||
55 | /** |
||
56 | * @return \ShippoClient\Entity\ServiceLevel |
||
57 | */ |
||
58 | public function getServiceLevel() |
||
64 | |||
65 | public function toArray() |
||
78 | } |
||
79 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: