Completed
Push — master ( 2bb920...810e98 )
by Rafael
02:04
created

ModifiedTrait::setModified()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Mero\Bundle\BaseBundle\Entity\Field;
4
5
/**
6
 * @author Rafael Mello <[email protected]>
7
 */
8
trait ModifiedTrait
9
{
10
    /**
11
     * @var \DateTime Date modified
12
     *
13
     * @ORM\Column(type="datetime", nullable=true)
14
     */
15
    protected $modified;
16
17
    /**
18
     * Returns registry modification date if any.
19
     *
20
     * @return null|\DateTime
21
     */
22
    public function getModified()
23
    {
24
        return $this->modified;
25
    }
26
27
    /**
28
     * Sets modified date.
29
     *
30
     * @param \DateTime $modified Date modified
31
     *
32
     * @return object
33
     */
34
    public function setModified(\DateTime $modified)
35
    {
36
        $this->modified = $modified;
37
38
        return $this;
39
    }
40
41
    /**
42
     * Method to update modified date.
43
     *
44
     * @ORM\PreUpdate
45
     */
46
    public function updateModifiedDate()
47
    {
48
        $this->modified = new \DateTime();
49
    }
50
}
51