Completed
Push — master ( 810e98...a03780 )
by Rafael
16:20
created

ModifiedTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 43
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getModified() 0 4 1
A setModified() 0 6 1
A updateModifiedDate() 0 4 1
1
<?php
2
3
namespace Mero\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