HasTimestamps   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onPreUpdate() 0 3 1
A onPrePersist() 0 4 1
1
<?php
2
3
namespace App\Traits;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
trait HasTimestamps
8
{
9
    /**
10
     * @ORM\Column(type="datetime")
11
     */
12
    private $createdAt;
13
14
    /**
15
     * @ORM\Column(type="datetime", nullable=true)
16
     */
17
    private $updatedAt;
18
19
    /**
20
     * @ORM\PrePersist()
21
     */
22
    public function onPrePersist(): void
23
    {
24
        $this->createdAt = new \DateTime();
25
        $this->updatedAt = new \DateTime();
26
    }
27
28
    /**
29
     * @ORM\PreUpdate()
30
     */
31
    public function onPreUpdate(): void
32
    {
33
        $this->updatedAt = new \DateTime();
34
    }
35
}