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 ( 2a6b46...0d82f1 )
by joseph
20s queued 14s
created

metaForUnicodeLanguageIdentifier()   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 11
cp 0
crap 2
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
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\UnicodeLanguageIdentifierFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
use Symfony\Component\Validator\Constraints\Language;
13
use Symfony\Component\Validator\Constraints\Length;
14
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
15
16
trait UnicodeLanguageIdentifierFieldTrait
17
{
18
19
    /**
20
     * @var string|null
21
     */
22
    private $unicodeLanguageIdentifier;
23
24
    /**
25
     * @SuppressWarnings(PHPMD.StaticAccess)
26
     * @param ClassMetadataBuilder $builder
27
     */
28
    public static function metaForUnicodeLanguageIdentifier(ClassMetadataBuilder $builder): void
29
    {
30
        $fieldBuilder = new FieldBuilder(
31
            $builder,
32
            [
33
                'fieldName' => UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
34
                'type'      => Type::STRING,
35
                'default'   => null,
36
            ]
37
        );
38
        $fieldBuilder
39
            ->columnName(MappingHelper::getColumnNameForField(
40
                UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER
41
            ))
42
            ->nullable()
43
            ->unique(false)
44
            ->length(50)
45
            ->build();
46
    }
47
48
49
    /**
50
     * Validates the property is a Unicode Language Identifier
51
     *
52
     * @param ValidatorClassMetaData $metadata
53
     */
54
    protected static function validatorMetaForPropertyUnicodeLanguageIdentifier(ValidatorClassMetaData $metadata): void
55
    {
56
        $metadata->addPropertyConstraints(
57
            UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
58
            [
59
                new Language(),
60
                new Length(
61
                    [
62
                        'min' => 0,
63
                        'max' => 50,
64
                    ]
65
                ),
66
            ]
67
        );
68
    }
69
70
    /**
71
     * @return string|null
72
     */
73
    public function getUnicodeLanguageIdentifier(): ?string
74
    {
75
        if (null === $this->unicodeLanguageIdentifier) {
76
            return UnicodeLanguageIdentifierFieldInterface::DEFAULT_UNICODE_LANGUAGE_IDENTIFIER;
77
        }
78
79
        return $this->unicodeLanguageIdentifier;
80
    }
81
82
    /**
83
     * @param string|null $unicodeLanguageIdentifier
84
     *
85
     * @return self
86
     */
87
    private function setUnicodeLanguageIdentifier(?string $unicodeLanguageIdentifier): self
88
    {
89
        $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

89
        $this->/** @scrutinizer ignore-call */ 
90
               updatePropertyValue(
Loading history...
90
            UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
91
            $unicodeLanguageIdentifier
92
        );
93
94
        return $this;
95
    }
96
}
97