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

metaForUnicodeLanguageIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1.0876

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 1
dl 0
loc 18
ccs 10
cts 18
cp 0.5556
crap 1.0876
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\Mapping\ClassMetadata as ValidatorClassMetaData;
12
13
trait UnicodeLanguageIdentifierFieldTrait
14
{
15
16
    /**
17
     * @var string|null
18
     */
19
    private $unicodeLanguageIdentifier;
20
21
    /**
22
     * @SuppressWarnings(PHPMD.StaticAccess)
23
     * @param ClassMetadataBuilder $builder
24
     */
25 6
    public static function metaForUnicodeLanguageIdentifier(ClassMetadataBuilder $builder): void
26
    {
27 6
        $fieldBuilder = new FieldBuilder(
28 6
            $builder,
29
            [
30 6
                'fieldName' => UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
31
                'type'      => Type::STRING,
32
                'default'   => null,
33
            ]
34
        );
35
        $fieldBuilder
36 6
            ->columnName(MappingHelper::getColumnNameForField(
37 6
                UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER
38
            ))
39 6
            ->nullable(true)
40 6
            ->unique(false)
41 6
            ->length(50)
42 6
            ->build();
43 6
    }
44
45
46
    /**
47
     * Validates the property is a Unicode Language Identifier
48
     *
49
     * @param ValidatorClassMetaData $metadata
50
     */
51 6
    protected static function validatorMetaForPropertyUnicodeLanguageIdentifier(ValidatorClassMetaData $metadata): void
52
    {
53 6
        $metadata->addPropertyConstraint(
54 6
            UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
55 6
            new Language()
56
        );
57 6
    }
58
59
    /**
60
     * @return string|null
61
     */
62 6
    public function getUnicodeLanguageIdentifier(): ?string
63
    {
64 6
        if (null === $this->unicodeLanguageIdentifier) {
65 6
            return UnicodeLanguageIdentifierFieldInterface::DEFAULT_UNICODE_LANGUAGE_IDENTIFIER;
66
        }
67
68 6
        return $this->unicodeLanguageIdentifier;
69
    }
70
71
    /**
72
     * @param string|null $unicodeLanguageIdentifier
73
     *
74
     * @return self
75
     */
76 6
    private function setUnicodeLanguageIdentifier(?string $unicodeLanguageIdentifier): self
77
    {
78 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

78
        $this->/** @scrutinizer ignore-call */ 
79
               updatePropertyValue(
Loading history...
79 6
            UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
80 6
            $unicodeLanguageIdentifier
81
        );
82
83 6
        return $this;
84
    }
85
}
86