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

IdGeneratorUserTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

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
    /** @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