Completed
Push — master ( 31741c...acf815 )
by Benjamin
11:01 queued 06:10
created

TimeStampableTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getUpdatedAt() 0 3 1
A setUpdatedAt() 0 5 1
A setUpdatedAtValue() 0 3 1
A setCreatedAt() 0 5 1
A getCreatedAt() 0 3 1
A setCreatedAtValue() 0 3 1
1
<?php
2
3
namespace Obblm\Core\Entity\Traits;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\HasLifecycleCallbacks
9
 */
10
trait TimeStampableTrait
11
{
12
    /**
13
     * @ORM\Column(type="datetime", nullable=true)
14
     */
15
    private $createdAt;
16
    /**
17
     * @ORM\Column(type="datetime", nullable=true)
18
     */
19
    private $updatedAt;
20
21
    public function getCreatedAt(): ?\DateTimeInterface
22
    {
23
        return $this->createdAt;
24
    }
25
26
    public function setCreatedAt(\DateTimeInterface $createdAt): self
27
    {
28
        $this->createdAt = $createdAt;
29
30
        return $this;
31
    }
32
33
    public function getUpdatedAt(): ?\DateTimeInterface
34
    {
35
        return $this->updatedAt;
36
    }
37
38
    public function setUpdatedAt(\DateTimeInterface $updatedAt): self
39
    {
40
        $this->updatedAt = $updatedAt;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @ORM\PrePersist
47
     */
48
    public function setCreatedAtValue()
49
    {
50
        $this->createdAt = new \DateTime();
51
    }
52
53
    /**
54
     * @ORM\PreUpdate
55
     */
56
    public function setUpdatedAtValue()
57
    {
58
        $this->updatedAt = new \DateTime();
59
    }
60
}
61