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 ( 810b23...1b23c8 )
by joseph
12s
created

Fields/Traits/String/UniqueStringFieldTrait.php (1 issue)

Labels
Severity
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\Entity\Interfaces\ValidatedEntityInterface;
12
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
13
use EdmondsCommerce\DoctrineStaticMeta\Schema\Database;
14
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
15
16
// phpcs:enable
17
trait UniqueStringFieldTrait
18
{
19
20
    /**
21
     * @var string|null
22
     */
23
    private $uniqueString;
24
25
    /**
26
     * @param ClassMetadataBuilder $builder
27
     * @SuppressWarnings(PHPMD.StaticAccess)
28
     */
29 1
    public static function metaForUniqueString(ClassMetadataBuilder $builder): void
30
    {
31 1
        $fieldBuilder = new FieldBuilder(
32 1
            $builder,
33
            [
34 1
                'fieldName' => UniqueStringFieldInterface::PROP_UNIQUE_STRING,
35
                'type'      => Type::STRING,
36
                'default'   => UniqueStringFieldInterface::DEFAULT_UNIQUE_STRING,
37
            ]
38
        );
39
        $fieldBuilder
40 1
            ->columnName(MappingHelper::getColumnNameForField(UniqueStringFieldInterface::PROP_UNIQUE_STRING))
41 1
            ->nullable(null === UniqueStringFieldInterface::DEFAULT_UNIQUE_STRING)
42 1
            ->unique(true)
43 1
            ->length(Database::MAX_VARCHAR_LENGTH)
44 1
            ->build();
45 1
        $builder->addIndex(
46
            [
47 1
                MappingHelper::getColumnNameForField(UniqueStringFieldInterface::PROP_UNIQUE_STRING),
48
            ],
49 1
            MappingHelper::getColumnNameForField(UniqueStringFieldInterface::PROP_UNIQUE_STRING)
50
        );
51 1
    }
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
     * Remove the PHPMD suppressed warning once you start setting constraints
59
     *
60
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
61
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
62
     *
63
     * @param ValidatorClassMetaData $metadata
64
     *
65
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
66
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
67
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
68
     */
69 2
    protected static function validatorMetaForUniqueString(ValidatorClassMetaData $metadata)
70
    {
71
        //        $metadata->addPropertyConstraint(
72
        //            UniqueStringFieldInterface::PROP_UNIQUE_STRING,
73
        //            new NotBlank()
74
        //        );
75 2
    }
76
77
    /**
78
     * @return string|null
79
     */
80 2
    public function getUniqueString(): ?string
81
    {
82 2
        if (null === $this->uniqueString) {
83 1
            return UniqueStringFieldInterface::DEFAULT_UNIQUE_STRING;
84
        }
85
86 2
        return $this->uniqueString;
87
    }
88
89
    /**
90
     * @param string|null $uniqueString
91
     *
92
     * @return self
93
     */
94 2
    public function setUniqueString(?string $uniqueString): self
95
    {
96 2
        $this->updatePropertyValueThenValidateAndNotify(
0 ignored issues
show
It seems like updatePropertyValueThenValidateAndNotify() 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

96
        $this->/** @scrutinizer ignore-call */ 
97
               updatePropertyValueThenValidateAndNotify(
Loading history...
97 2
            UniqueStringFieldInterface::PROP_UNIQUE_STRING,
98 2
            $uniqueString
99
        );
100
101 2
        return $this;
102
    }
103
}
104