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

Model   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 5
dl 0
loc 44
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setModelValue() 0 4 1
A getModelValue() 0 4 1
A populate() 0 4 1
A setCreatedAt() 0 4 1
A jsonSerialize() 0 9 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