Completed
Push — master ( 0be8e1...585ca2 )
by Daniel
59:26 queued 46:02
created

TimestampedEntityTrait::getModified()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity;
4
5
use DateTime;
6
use DateTimeImmutable;
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * @ORM\EntityListeners({"Silverback\ApiComponentBundle\EntityListener\TimestampedEntityListener"})
11
 */
12
trait TimestampedEntityTrait
13
{
14
    /**
15
     * @ORM\Column(type="datetime_immutable", options={"default" = "CURRENT_TIMESTAMP"})
16
     * @var DateTimeImmutable
17
     */
18
    protected $created;
19
20
    /**
21
     * @ORM\Column(type="datetime", options={"default" = "CURRENT_TIMESTAMP"})
22
     * @var DateTime
23
     */
24
    protected $modified;
25
26
    /**
27
     * @return DateTimeImmutable
28
     */
29
    public function getCreated(): DateTimeImmutable
30
    {
31
        return $this->created;
32
    }
33
34
    /**
35
     * @param DateTimeImmutable $created
36
     * @return static
37
     */
38
    public function setCreated(DateTimeImmutable $created)
39
    {
40
        if (!$this->created) {
41
            $this->created = $created;
42
        }
43
        return $this;
44
    }
45
46
    /**
47
     * @return DateTime
48
     */
49
    public function getModified(): DateTime
50
    {
51
        return $this->modified;
52
    }
53
54
    /**
55
     * @param DateTime $modified
56
     * @return static
57
     */
58
    public function setModified(DateTime $modified)
59
    {
60
        $this->modified = $modified;
61
        return $this;
62
    }
63
}
64