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.
Completed
Pull Request — master (#131)
by joseph
33:18 queued 10:43
created

UuidFieldTrait::setId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
ccs 0
cts 6
cp 0
crap 6
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey;
4
5
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
6
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
7
use Ramsey\Uuid\Doctrine\UuidOrderedTimeGenerator;
8
use Ramsey\Uuid\UuidInterface;
9
10
trait UuidFieldTrait
11
{
12
    /**
13
     * @var UuidInterface
14
     */
15
    private $id;
16
17
    /**
18
     * @param ClassMetadataBuilder $builder
19
     *
20
     * @see https://github.com/ramsey/uuid-doctrine#innodb-optimised-binary-uuids
21
     */
22 3
    protected static function metaForId(ClassMetadataBuilder $builder): void
23
    {
24 3
        $builder->createField('id', MappingHelper::TYPE_UUID)
25 3
                ->makePrimaryKey()
26 3
                ->nullable(false)
27 3
                ->unique(true)
28 3
                ->generatedValue('CUSTOM')
29 3
                ->setCustomIdGenerator(UuidOrderedTimeGenerator::class)
30 3
                ->build();
31 3
    }
32
33 3
    public function getId(): ?UuidInterface
34
    {
35 3
        return $this->id;
36
    }
37
38
    /**
39
     * @param UuidInterface $id
40
     *
41
     * @return UuidFieldTrait
42
     */
43
    public function setId(UuidInterface $id)
44
    {
45
        if (null !== $this->id) {
46
            throw new \RuntimeException(
47
                'You can not overwrite a UUID that has alreasy been set.' .
48
                ' This method should only be used for setting the ID on newly created Entities'
49
            );
50
        }
51
        $this->id = $id;
52
53
        return $this;
54
    }
55
}
56