ModifiedTrait::getModified()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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