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.

BinaryUuidFieldTrait::getBinaryUuid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\Binary;
6
7
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
8
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Binary\BinaryUuidFieldInterface;
10
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
11
use Ramsey\Uuid\UuidInterface;
12
13
/**
14
 * Trait BinaryUuidFieldTrait
15
 *
16
 * This field allows you to set a UUID that is generated elsewhere than the database.
17
 * This is as opposed to using a UUID primary key which is generated by the database
18
 * - eg
19
 * \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\UuidFieldTrait
20
 */
21
trait BinaryUuidFieldTrait
22
{
23
24
    /**
25
     * @var UuidInterface|null
26
     */
27
    private $binaryUuid;
28
29
    /**
30
     * @SuppressWarnings(PHPMD.StaticAccess)
31
     * @param ClassMetadataBuilder $builder
32
     */
33
    public static function metaForBinaryUuid(ClassMetadataBuilder $builder): void
34
    {
35
        $columnName   = MappingHelper::getColumnNameForField(
36
            BinaryUuidFieldInterface::PROP_BINARY_UUID
37
        );
38
        $fieldBuilder = new FieldBuilder(
39
            $builder,
40
            [
41
                'fieldName' => BinaryUuidFieldInterface::PROP_BINARY_UUID,
42
                'type'      => MappingHelper::TYPE_UUID,
43
            ]
44
        );
45
        $fieldBuilder->columnName($columnName)
46
                     ->nullable()
47
                     ->unique(false)
48
                     ->build();
49
        $builder->addIndex([$columnName], $columnName . '_idx');
50
    }
51
52
    /**
53
     * @return UuidInterface|null
54
     */
55
    public function getBinaryUuid(): ?UuidInterface
56
    {
57
        return $this->binaryUuid;
58
    }
59
60
    /**
61
     * @param UuidInterface $binaryUuid
62
     *
63
     * @return self
64
     */
65
    private function setBinaryUuid(?UuidInterface $binaryUuid): self
66
    {
67
        $this->updatePropertyValue(
0 ignored issues
show
Bug introduced by
It seems like updatePropertyValue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

67
        $this->/** @scrutinizer ignore-call */ 
68
               updatePropertyValue(
Loading history...
68
            BinaryUuidFieldInterface::PROP_BINARY_UUID,
69
            $binaryUuid
70
        );
71
72
        return $this;
73
    }
74
}
75