Passed
Push — master ( 3ec415...9f2f47 )
by Daniel
16:25
created

IdTrait::setId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[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
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentsBundle\Entity\Utility;
15
16
use ApiPlatform\Core\Annotation\ApiProperty;
17
use Doctrine\ORM\Mapping as ORM;
18
use Ramsey\Uuid\Doctrine\UuidGenerator;
19
use Ramsey\Uuid\Uuid;
20
use Ramsey\Uuid\UuidInterface;
21
22
/**
23
 * Reusable trait by application developer so keep annotations as we cannot map with XML.
24
 *
25
 * @author Daniel West <[email protected]>
26
 */
27
trait IdTrait
28
{
29
    /**
30
     * Must allow return `null` for lowest dependencies.
31
     *
32
     * @ORM\Id
33
     * @ORM\Column(type="uuid", unique=true, nullable=false)
34
     * @ORM\GeneratedValue(strategy="CUSTOM")
35
     * @ORM\CustomIdGenerator(class=UuidGenerator::class)
36
     * @ApiProperty(readable=false)
37
     */
38
    protected ?UuidInterface $id = null;
39
40 5
    public function getId(): ?UuidInterface
41
    {
42 5
        return $this->id;
43
    }
44
}
45