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.
Passed
Pull Request — master (#194)
by joseph
26:34
created

validatorMetaForPropertyUniqueString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.008

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 5
cp 0.8
crap 1.008
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
4
5
// phpcs:disable
6
7
use Doctrine\DBAL\Types\Type;
8
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
9
use Doctrine\ORM\Mapping\Builder\FieldBuilder;
10
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\UniqueStringFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
use Symfony\Component\Validator\Constraints\Length;
13
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
14
15
// phpcs:enable
16
trait UniqueStringFieldTrait
17
{
18
19
    /**
20
     * @var string|null
21
     */
22
    private $uniqueString;
23
24
    /**
25
     * @param ClassMetadataBuilder $builder
26
     * @SuppressWarnings(PHPMD.StaticAccess)
27
     */
28 2
    public static function metaForUniqueString(ClassMetadataBuilder $builder): void
29
    {
30 2
        $fieldBuilder = new FieldBuilder(
31 2
            $builder,
32
            [
33 2
                'fieldName' => UniqueStringFieldInterface::PROP_UNIQUE_STRING,
34
                'type'      => Type::STRING,
35
                'default'   => UniqueStringFieldInterface::DEFAULT_UNIQUE_STRING,
36
            ]
37
        );
38
        $fieldBuilder
39 2
            ->columnName(MappingHelper::getColumnNameForField(UniqueStringFieldInterface::PROP_UNIQUE_STRING))
40 2
            ->nullable(false)
41 2
            ->unique(true)
42 2
            ->length(UniqueStringFieldInterface::LENGTH_UNIQUE_STRING)
43 2
            ->build();
44 2
    }
45
46
    /**
47
     * @return string|null
48
     */
49 2
    public function getUniqueString(): ?string
50
    {
51 2
        if (null === $this->uniqueString) {
52
            return UniqueStringFieldInterface::DEFAULT_UNIQUE_STRING;
53
        }
54
55 2
        return $this->uniqueString;
56
    }
57
58
    /**
59
     *
60
     */
61 2
    protected static function validatorMetaForPropertyUniqueString(ValidatorClassMetaData $metadata): void
62
    {
63 2
        $metadata->addPropertyConstraint(
64 2
            UniqueStringFieldInterface::PROP_UNIQUE_STRING,
65 2
            new Length(['min' => 0, 'max' => UniqueStringFieldInterface::LENGTH_UNIQUE_STRING])
66
        );
67 2
    }
68
69
    /**
70
     * @param string|null $uniqueString
71
     *
72
     * @return self
73
     */
74 2
    private function setUniqueString(?string $uniqueString): self
75
    {
76 2
        $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

76
        $this->/** @scrutinizer ignore-call */ 
77
               updatePropertyValue(
Loading history...
77 2
            UniqueStringFieldInterface::PROP_UNIQUE_STRING,
78 2
            $uniqueString
79
        );
80
81 2
        return $this;
82
    }
83
}
84