Conditions | 1 |
Paths | 1 |
Total Lines | 18 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public function transform(Sale $sale) |
||
18 | { |
||
19 | return [ |
||
20 | 'id' => $sale->id, |
||
21 | 'name' => $sale->name, |
||
22 | 'address' => $sale->address, |
||
23 | 'isShop' => is_null($this->shop_id), |
||
|
|||
24 | 'make' => [ |
||
25 | 'id' => $sale->make->id, |
||
26 | 'name' => $sale->make->name, |
||
27 | ], |
||
28 | 'bought' => [ |
||
29 | 'timestamp' => $sale->created_at->getTimestamp(), |
||
30 | 'date' => $sale->created_at->toFormattedDateString(), |
||
31 | 'readable' => $sale->created_at->diffForHumans(), |
||
32 | ], |
||
33 | ]; |
||
34 | } |
||
35 | } |
||
36 |
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: