HasDeletedAtDate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 15
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDeletedAt() 0 3 1
A setDeletedAt() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bone\BoneDoctrine\Traits;
6
7
use DateTimeImmutable;
8
use DateTimeInterface;
9
use DateTimeZone;
10
use Doctrine\ORM\Mapping as ORM;
11
12
#[ORM\HasLifecycleCallbacks]
13
trait HasDeletedAtDate
14
{
15
    #[ORM\Column(type: 'datetime_immutable', nullable:true)]
16
    private ?DateTimeImmutable $deletedAt = null;
17
18 1
    public function getDeletedAt(): DateTimeInterface
19
    {
20 1
        return $this->deletedAt;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->deletedAt 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...
21
    }
22
23 1
    #[ORM\PreUpdate]
24
    public function setDeletedAt(): void
25
    {
26 1
        $this->deletedAt = new DateTimeImmutable('now', new DateTimeZone('UTC'));
27
    }
28
}
29