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

HasUpdatedAtDate   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpdatedAt() 0 3 1
A getUpdatedAt() 0 3 1
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