IdTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 15
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\Metadata\ApiProperty;
17
use Doctrine\ORM\Mapping as ORM;
18
use Ramsey\Uuid\Doctrine\UuidGenerator;
19
use Ramsey\Uuid\UuidInterface;
20
21
/**
22
 * Reusable trait by application developer so keep annotations as we cannot map with XML.
23
 *
24
 * @author Daniel West <[email protected]>
25
 */
26
trait IdTrait
27
{
28
    /**
29
     * Must allow return `null` for lowest dependencies.
30
     */
31
    #[ORM\Id]
32
    #[ORM\Column(type: 'uuid', unique: true, nullable: false)]
33
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
34
    #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
35
    #[ApiProperty(readable: false, identifier: true)]
36
    protected ?UuidInterface $id = null;
37
38 7
    public function getId(): ?UuidInterface
39
    {
40 7
        return $this->id;
41
    }
42
}
43