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

IdTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 16
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
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