Passed
Push — master ( 7ac1d2...b222b2 )
by Derek Stephen
10:23
created

HasUpdatedAtDate::getUpdatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bone\BoneDoctrine\Traits;
6
7
use DateTimeImmutable;
8
use Doctrine\ORM\Mapping as ORM;
9
10
/**
11
 * @ORM\HasLifecycleCallbacks
12
 */
13
trait HasUpdatedAtDate
14
{
15
    /**
16
     * @ORM\Column(type="datetimm", nullable=true)
17
     */
18
    private ?DateTimeImmutable $updatedAt;
19
20
    public function getUpdatedAt(): \DateTimeInterface
21
    {
22
        return $this->updatedAt;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->updatedAt could return the type null which is incompatible with the type-hinted return DateTimeInterface. Consider adding an additional type-check to rule them out.
Loading history...
23
    }
24
25
    /**
26
     * @@ORM\PreUpdate
27
     */
28
    public function setUpdatedAt(): void
29
    {
30
        $this->updatedAt = new DateTimeImmutable();
31
    }
32
}
33