GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#152)
by joseph
15:36
created

AbstractUuidFieldTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 42
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A injectUuid() 0 4 2
A setId() 0 9 2
A getId() 0 3 1
A getUuid() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Debug\DebugEntityDataObjectIds;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Factories\UuidFactory;
7
use Ramsey\Uuid\UuidInterface;
8
9
trait AbstractUuidFieldTrait
10
{
11
    /**
12
     * @var UuidInterface
13
     */
14
    private $id;
15
16
    use DebugEntityDataObjectIds;
17
18
    abstract public static function buildUuid(UuidFactory $uuidFactory): UuidInterface;
19
20
    /**
21
     * This is leveraging the setter injection that happens on Entity creation to ensure that the UUID is set
22
     *
23
     * @param UuidFactory $uuidFactory
24
     */
25
    public function injectUuid(UuidFactory $uuidFactory)
26
    {
27
        if (null === $this->id) {
28
            $this->setId(self::buildUuid($uuidFactory));
29
        }
30
    }
31
32
    public function getId(): UuidInterface
33
    {
34
        return $this->id;
35
    }
36
37
    public function getUuid(): UuidInterface
38
    {
39
        return $this->id;
40
    }
41
42
    private function setId(UuidInterface $uuid): self
43
    {
44
        if (null !== $this->id) {
45
            throw new \InvalidArgumentException('Trying to update ID when it has already been set');
46
        }
47
        $this->id = $uuid;
48
        $this->initDebugIds(true);
49
50
        return $this;
51
    }
52
}
53