IdTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 25
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isPersistedInDatabase() 0 3 1
A setId() 0 3 1
A getId() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the TheAlternativeZurich/events project.
5
 *
6
 * (c) Florian Moser <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Entity\Traits;
13
14
use Doctrine\ORM\Mapping as ORM;
15
16
/*
17
 * the id used in the entities
18
 */
19
20
trait IdTrait
21
{
22
    /**
23
     * @var string|null
24
     *                  will be null when not inserted into the db yet
25
     *
26
     * @ORM\Id
27
     * @ORM\Column(name="id", type="guid")
28
     * @ORM\GeneratedValue(strategy="UUID")
29
     */
30
    private $id;
31
32
    public function getId(): ?string
33
    {
34
        return $this->id;
35
    }
36
37
    public function setId(string $id): void
38
    {
39
        $this->id = $id;
40
    }
41
42
    public function isPersistedInDatabase(): bool
43
    {
44
        return null !== $this->id;
45
    }
46
}
47