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
Push — master ( a48bd8...83d092 )
by joseph
16:18 queued 18s
created

SettableUuidFieldTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 76
ccs 0
cts 38
cp 0
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A metaForSettableUuid() 0 16 1
A validatorMetaForPropertySettableUuid() 0 5 1
A setSettableUuid() 0 8 1
A getSettableUuid() 0 7 2
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
4
5
use Doctrine\DBAL\Types\Type;
6
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
7
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\SettableUuidFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
10
use Symfony\Component\Validator\Constraints\Uuid;
11
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
12
13
/**
14
 * Trait SettableUuidFieldTrait
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
 * @package EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String
22
 */
23
trait SettableUuidFieldTrait
24
{
25
26
    /**
27
     * @var string|null
28
     */
29
    private $settableUuid;
30
31
    /**
32
     * @SuppressWarnings(PHPMD.StaticAccess)
33
     * @param ClassMetadataBuilder $builder
34
     */
35
    public static function metaForSettableUuid(ClassMetadataBuilder $builder): void
36
    {
37
        $fieldBuilder = new FieldBuilder(
38
            $builder,
39
            [
40
                'fieldName' => SettableUuidFieldInterface::PROP_SETTABLE_UUID,
41
                'type'      => Type::STRING,
42
                'default'   => SettableUuidFieldInterface::DEFAULT_SETTABLE_UUID,
43
            ]
44
        );
45
        $fieldBuilder
46
            ->columnName(MappingHelper::getColumnNameForField(SettableUuidFieldInterface::PROP_SETTABLE_UUID))
47
            ->nullable(true)
48
            ->unique(true)
49
            ->length(100)
50
            ->build();
51
    }
52
53
    /**
54
     * This method sets the validation for this field.
55
     *
56
     * You should add in as many relevant property constraints as you see fit.
57
     *
58
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
59
     *
60
     * @param ValidatorClassMetaData $metadata
61
     *
62
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
63
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
64
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
65
     */
66
    protected static function validatorMetaForPropertySettableUuid(ValidatorClassMetaData $metadata): void
67
    {
68
        $metadata->addPropertyConstraint(
69
            SettableUuidFieldInterface::PROP_SETTABLE_UUID,
70
            new Uuid()
71
        );
72
    }
73
74
    /**
75
     * @return string|null
76
     */
77
    public function getSettableUuid(): ?string
78
    {
79
        if (null === $this->settableUuid) {
80
            return SettableUuidFieldInterface::DEFAULT_SETTABLE_UUID;
81
        }
82
83
        return $this->settableUuid;
84
    }
85
86
    /**
87
     * @param string|null $settableUuid
88
     *
89
     * @return self
90
     */
91
    private function setSettableUuid(?string $settableUuid): self
92
    {
93
        $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

93
        $this->/** @scrutinizer ignore-call */ 
94
               updatePropertyValue(
Loading history...
94
            SettableUuidFieldInterface::PROP_SETTABLE_UUID,
95
            $settableUuid
96
        );
97
98
        return $this;
99
    }
100
}
101