EntityIdTrait::createUuid()   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
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: siim
5
 * Date: 21.01.19
6
 * Time: 8:42
7
 */
8
9
namespace Sf4\Api\Entity\Traits;
10
11
use Doctrine\ORM\Mapping as ORM;
12
use Ramsey\Uuid\UuidInterface;
13
use Sf4\Api\Utils\Traits\CreateNewTokenTrait;
14
15
trait EntityIdTrait
16
{
17
18
    use CreateNewTokenTrait;
19
20
    /**
21
     * The unique auto incremented primary key.
22
     *
23
     * @var int|null
24
     *
25
     * @ORM\Id
26
     * @ORM\Column(type="integer", options={"unsigned": true})
27
     * @ORM\GeneratedValue
28
     */
29
    private $id;
30
31
    /**
32
     * The internal primary identity key.
33
     *
34
     * @var UuidInterface
35
     *
36
     * @ORM\Column(type="uuid", unique=true)
37
     */
38
    private $uuid;
39
40
    public function getId(): ?int
41
    {
42
        return $this->id;
43
    }
44
45
    public function getUuid(): UuidInterface
46
    {
47
        return $this->uuid;
48
    }
49
50
    public function createUuid(): void
51
    {
52
        $this->uuid = $this->createNewToken();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createNewToken() of type string is incompatible with the declared type Ramsey\Uuid\UuidInterface of property $uuid.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
53
    }
54
}
55