IdGeneratorUserTrait::setIdGenerator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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