1 | <?php |
||
2 | |||
3 | namespace AloiaCms\Models\Traits; |
||
4 | |||
5 | use Carbon\Carbon; |
||
6 | |||
7 | trait Updatable |
||
8 | { |
||
9 | /** |
||
10 | * Set the update date |
||
11 | * |
||
12 | * @param Carbon $update_date |
||
13 | * @return $this |
||
14 | */ |
||
15 | 2 | public function setUpdateDate(Carbon $update_date) |
|
16 | { |
||
17 | 2 | $this->matter['update_date'] = $update_date->toDateTimeString(); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
18 | $this->has_changes = true; |
||
0 ignored issues
–
show
|
|||
19 | 2 | ||
20 | return $this; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Get the update date |
||
25 | * |
||
26 | * @return Carbon|null |
||
27 | 3 | */ |
|
28 | public function getUpdateDate() |
||
29 | 3 | { |
|
30 | 1 | if (!isset($this->matter['update_date']) || empty($this->matter['update_date'])) { |
|
31 | return null; |
||
32 | } |
||
33 | 2 | ||
34 | return Carbon::createFromFormat('Y-m-d H:i:s', $this->matter['update_date']); |
||
0 ignored issues
–
show
The expression
return Carbon\Carbon::cr...>matter['update_date']) could also return false which is incompatible with the documented return type Carbon\Carbon|null . Did you maybe forget to handle an error condition?
If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled. ![]() |
|||
35 | } |
||
36 | } |
||
37 |