Issues (15)

src/Concerns/Timestampable.php (2 issues)

1
<?php
2
3
namespace Isswp101\Persimmon\Concerns;
4
5
use DateTime;
6
7
trait Timestampable
8
{
9
    protected bool $timestamps = true;
10
11
    private function touch(bool $exists): void
12
    {
13
        if (!$this->timestamps) {
14
            return;
15
        }
16
17
        $dt = new DateTime();
18
19
        $now = $dt->format(DateTime::ISO8601);
20
21
        $this->created_at = !$exists ? $now : $this->created_at;
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
        $this->updated_at = $now;
0 ignored issues
show
Bug Best Practice introduced by
The property updated_at does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
    }
24
}
25