Passed
Push — master ( f85738...3d85c1 )
by Peter
04:52
created

IdGeneratorUserTrait::getIdGenerator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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
    /** @var IIdGenerator */
13
    protected $idGenerator;
14
15
    /**
16
     * @param IIdGenerator $idGenerator
17
     */
18
    public function setIdGenerator(IIdGenerator $idGenerator)
19
    {
20
        $this->idGenerator = $idGenerator;
21
    }
22
23
    /**
24
     * @return IIdGenerator
25
     */
26
    protected function getIdGenerator(): IIdGenerator
27
    {
28
        if (!$this->idGenerator) {
29
            $this->idGenerator = new UuidV4Generator();
30
        }
31
32
        return $this->idGenerator;
33
    }
34
}
35