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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 64.71%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 44
rs 10
c 0
b 0
f 0
ccs 11
cts 17
cp 0.6471
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A metaForId() 0 9 1
A getId() 0 3 1
A setId() 0 11 2
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