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 (#198)
by joseph
28:16
created

BinaryUuidFieldTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 52
ccs 0
cts 29
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBinaryUuid() 0 3 1
A setBinaryUuid() 0 8 1
A metaForBinaryUuid() 0 17 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\Binary;
4
5
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
6
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Binary\BinaryUuidFieldInterface;
8
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
9
use Ramsey\Uuid\UuidInterface;
10
11
/**
12
 * Trait BinaryUuidFieldTrait
13
 *
14
 * This field allows you to set a UUID that is generated elsewhere than the database.
15
 * This is as opposed to using a UUID primary key which is generated by the database
16
 * - eg
17
 * \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\UuidFieldTrait
18
 */
19
trait BinaryUuidFieldTrait
20
{
21
22
    /**
23
     * @var UuidInterface|null
24
     */
25
    private $binaryUuid;
26
27
    /**
28
     * @SuppressWarnings(PHPMD.StaticAccess)
29
     * @param ClassMetadataBuilder $builder
30
     */
31
    public static function metaForBinaryUuid(ClassMetadataBuilder $builder): void
32
    {
33
        $columnName   = MappingHelper::getColumnNameForField(
34
            BinaryUuidFieldInterface::PROP_BINARY_UUID
35
        );
36
        $fieldBuilder = new FieldBuilder(
37
            $builder,
38
            [
39
                'fieldName' => BinaryUuidFieldInterface::PROP_BINARY_UUID,
40
                'type'      => MappingHelper::TYPE_UUID,
41
            ]
42
        );
43
        $fieldBuilder->columnName($columnName)
44
                     ->nullable(true)
45
                     ->unique(false)
46
                     ->build();
47
        $builder->addIndex([$columnName], $columnName . '_idx');
48
    }
49
50
    /**
51
     * @return UuidInterface|null
52
     */
53
    public function getBinaryUuid(): ?UuidInterface
54
    {
55
        return $this->binaryUuid;
56
    }
57
58
    /**
59
     * @param UuidInterface $binaryUuid
60
     *
61
     * @return self
62
     */
63
    private function setBinaryUuid(?UuidInterface $binaryUuid): self
64
    {
65
        $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

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