Completed
Pull Request — v2 (#7)
by Guillaume
01:25
created

Model::setCreatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Tests;
4
5
use ETNA\Doctrine\Extensions\AutoIncrementID;
6
use ETNA\Doctrine\Extensions\CreatedAt;
7
use ETNA\Doctrine\Extensions\UpdatedAt;
8
use ETNA\Doctrine\Extensions\DoNotDelete;
9
use ETNA\Doctrine\Entity\AbstractEntity;
10
11
/**
12
 * @Entity(repositoryClass="Tests\ModelRepository")
13
 * @Table(name="model")
14
 * @HasLifecycleCallbacks
15
 */
16
class Model extends AbstractEntity
17
{
18
    use AutoIncrementID;
19
    use CreatedAt;
20
    use UpdatedAt;
21
    use DoNotDelete;
22
23
    private $model_value;
24
25
    public function __construct()
26
    {
27
        $this->model_value = '';
28
    }
29
30
    public function setModelValue($value)
31
    {
32
        $this->model_value = $value;
33
    }
34
35
    public function getModelValue()
36
    {
37
        return $this->model_value;
38
    }
39
40
    public function populate($date)
41
    {
42
        $this->created_at = $this->updated_at = $this->deleted_at = $date;
43
    }
44
45
    public function setCreatedAt(\DateTime $created_at)
46
    {
47
        $this->created_at = $created_at;
48
    }
49
50
    public function jsonSerialize()
51
    {
52
        return [
53
            'id'         => $this->getId(),
54
            'created_at' => $this->getCreatedAt(),
55
            'updated_at' => $this->getUpdatedAt(),
56
            'deleted_at' => $this->getDeletedAt()
57
        ];
58
    }
59
}
60