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 ( 08e101...6f7bef )
by joseph
23:56 queued 01:38
created

metaForLocaleIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 1
dl 0
loc 18
ccs 0
cts 18
cp 0
crap 2
rs 9.8666
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\LocaleIdentifierFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
use Symfony\Component\Validator\Constraints\Length;
13
use Symfony\Component\Validator\Constraints\Locale;
14
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
15
16
// phpcs:enable
17
trait LocaleIdentifierFieldTrait
18
{
19
20
    /**
21
     * @var string|null
22
     */
23
    private $localeIdentifier;
24
25
    /**
26
     * @SuppressWarnings(PHPMD.StaticAccess)
27
     * @param ClassMetadataBuilder $builder
28
     */
29
    public static function metaForLocaleIdentifier(ClassMetadataBuilder $builder): void
30
    {
31
        $fieldBuilder = new FieldBuilder(
32
            $builder,
33
            [
34
                'fieldName' => LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER,
35
                'type'      => Type::STRING,
36
                'default'   => LocaleIdentifierFieldInterface::DEFAULT_LOCALE_IDENTIFIER,
37
            ]
38
        );
39
        $fieldBuilder
40
            ->columnName(
41
                MappingHelper::getColumnNameForField(LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER)
42
            )
43
            ->nullable(true)
44
            ->unique(false)
45
            ->length(50)
46
            ->build();
47
    }
48
49
    /**
50
     * This method sets the validation for this field.
51
     *
52
     * You should add in as many relevant property constraints as you see fit.
53
     *
54
     * @param ValidatorClassMetaData $metadata
55
     *
56
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
57
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
58
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
59
     */
60
    protected static function validatorMetaForPropertyLocaleIdentifier(ValidatorClassMetaData $metadata): void
61
    {
62
        $metadata->addPropertyConstraints(
63
            LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER,
64
            [
65
                new Locale(['canonicalize' => true]),
66
                new Length(
67
                    [
68
                        'min' => 0,
69
                        'max' => 50,
70
                    ]
71
                )
72
            ]
73
        );
74
    }
75
76
    /**
77
     * @return string|null
78
     */
79
    public function getLocaleIdentifier(): ?string
80
    {
81
        if (null === $this->localeIdentifier) {
82
            return LocaleIdentifierFieldInterface::DEFAULT_LOCALE_IDENTIFIER;
83
        }
84
85
        return $this->localeIdentifier;
86
    }
87
88
    /**
89
     * @param string|null $localeIdentifier
90
     *
91
     * @return self
92
     */
93
    private function setLocaleIdentifier(?string $localeIdentifier): self
94
    {
95
        $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

95
        $this->/** @scrutinizer ignore-call */ 
96
               updatePropertyValue(
Loading history...
96
            LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER,
97
            $localeIdentifier
98
        );
99
100
        return $this;
101
    }
102
}
103