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 (#139)
by joseph
34:01 queued 31:09
created

NonBinaryUuidFieldTrait::metaForId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 9
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
b 0
f 0
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\UuidGenerator;
8
use Ramsey\Uuid\UuidInterface;
9
10
/**
11
 * This trait implements a text based UUID primary key which will then be stored as a string
12
 */
13
trait NonBinaryUuidFieldTrait
14
{
15
    /**
16
     * @var UuidInterface
17
     */
18
    private $id;
19
20
    /**
21
     * @param ClassMetadataBuilder $builder
22
     *
23
     * @see https://github.com/ramsey/uuid-doctrine#usage
24
     */
25
    protected static function metaForId(ClassMetadataBuilder $builder): void
26
    {
27
        $builder->createField('id', MappingHelper::TYPE_NON_BINARY_UUID)
28
                ->makePrimaryKey()
29
                ->nullable(false)
30
                ->unique(true)
31
                ->generatedValue('CUSTOM')
32
                ->setCustomIdGenerator(UuidGenerator::class)
33
                ->build();
34
    }
35
36
    public function getId(): ?UuidInterface
37
    {
38
        return $this->id;
39
    }
40
41
    /**
42
     * @param UuidInterface $id
43
     *
44
     * @return UuidFieldTrait
45
     */
46
    public function setId(UuidInterface $id)
47
    {
48
        if (null !== $this->id) {
49
            throw new \RuntimeException(
50
                'You can not overwrite a UUID that has alreasy been set.' .
51
                ' This method should only be used for setting the ID on newly created Entities'
52
            );
53
        }
54
        $this->id = $id;
55
56
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type EdmondsCommerce\Doctrine...NonBinaryUuidFieldTrait which is incompatible with the documented return type EdmondsCommerce\Doctrine...imaryKey\UuidFieldTrait.
Loading history...
57
    }
58
}
59