IdGeneratorUserTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
c 0
b 0
f 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setIdGenerator() 0 3 1
A getIdGenerator() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Admin\Orm\DataMappers;
6
7
use Opulence\Orm\Ids\Generators\IIdGenerator;
8
use Opulence\Orm\Ids\Generators\UuidV4Generator;
9
10
trait IdGeneratorUserTrait
11
{
12
    protected ?IIdGenerator $idGenerator = null;
13
14
    /**
15
     * @param IIdGenerator $idGenerator
16
     */
17
    public function setIdGenerator(IIdGenerator $idGenerator)
18
    {
19
        $this->idGenerator = $idGenerator;
20
    }
21
22
    /**
23
     * @return IIdGenerator
24
     */
25
    protected function getIdGenerator(): IIdGenerator
26
    {
27
        if (!$this->idGenerator) {
28
            $this->idGenerator = new UuidV4Generator();
29
        }
30
31
        return $this->idGenerator;
32
    }
33
}
34