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 ( fd432d...bef2be )
by Ross
25s queued 11s
created

LocaleIdentifierFieldTrait::getLocaleIdentifier()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.1481

Importance

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

86
        $this->/** @scrutinizer ignore-call */ 
87
               updatePropertyValue(
Loading history...
87 6
            LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER,
88 6
            $localeIdentifier
89
        );
90
91 6
        return $this;
92
    }
93
}
94