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

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

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