Entity   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onPrePersist() 0 5 1
A onPreUpdate() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Common;
5
6
use DateTime;
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * @author Thiago Paes <[email protected]>
11
 * @ORM\MappedSuperclass(repositoryClass="Doctrine\ORM\EntityRepository")
12
 */
13
trait Entity
14
{
15
    /**
16
     * @ORM\PrePersist
17
     */
18
    public function onPrePersist()
19
    {
20
        $this->created = new DateTime();
0 ignored issues
show
Bug introduced by
The property created does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21
        $this->updated = new DateTime();
0 ignored issues
show
Bug introduced by
The property updated does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
    }
23
24
    /**
25
     * @ORM\PreUpdate
26
     */
27
    public function onPreUpdate()
28
    {
29
        $this->updated = new DateTime();
30
    }
31
}
32