| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function getLastActivityDateAttribute(): string |
||
| 13 | { |
||
| 14 | if ($this->last_activity === null || $this->last_activity->year == -1) { |
||
| 15 | return fragment('back.frontUsers.neverLoggedIn'); |
||
| 16 | } |
||
| 17 | |||
| 18 | $lastActivityDate = diff_date_for_humans($this->last_activity); |
||
| 19 | |||
| 20 | if (str_contains($lastActivityDate, 'second')) { |
||
| 21 | $lastActivityDate = fragment('back.frontUsers.justNow'); |
||
| 22 | } |
||
| 23 | |||
| 24 | return $lastActivityDate; |
||
| 25 | } |
||
| 26 | } |
||
| 27 |
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: