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 ( 34f827...08e101 )
by joseph
30s queued 13s
created

UnicodeLanguageIdentifierFieldTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 56.25%

Importance

Changes 0
Metric Value
eloc 27
c 0
b 0
f 0
dl 0
loc 79
ccs 27
cts 48
cp 0.5625
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A metaForUnicodeLanguageIdentifier() 0 18 1
A setUnicodeLanguageIdentifier() 0 8 1
A getUnicodeLanguageIdentifier() 0 7 2
A validatorMetaForPropertyUnicodeLanguageIdentifier() 0 10 1
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 6
    public static function metaForUnicodeLanguageIdentifier(ClassMetadataBuilder $builder): void
27
    {
28 6
        $fieldBuilder = new FieldBuilder(
29 6
            $builder,
30
            [
31 6
                'fieldName' => UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
32
                'type'      => Type::STRING,
33
                'default'   => null,
34
            ]
35
        );
36
        $fieldBuilder
37 6
            ->columnName(MappingHelper::getColumnNameForField(
38 6
                UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER
39
            ))
40 6
            ->nullable(true)
41 6
            ->unique(false)
42 6
            ->length(50)
43 6
            ->build();
44 6
    }
45
46
47
    /**
48
     * Validates the property is a Unicode Language Identifier
49
     *
50
     * @param ValidatorClassMetaData $metadata
51
     */
52 6
    protected static function validatorMetaForPropertyUnicodeLanguageIdentifier(ValidatorClassMetaData $metadata): void
53
    {
54 6
        $metadata->addPropertyConstraints(
55 6
            UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
56
            [
57 6
                new Language(),
58 6
                new Length(
59
                    [
60 6
                        'min' => 0,
61
                        'max' => 50,
62
                    ]
63
                ),
64
            ]
65
        );
66 6
    }
67
68
    /**
69
     * @return string|null
70
     */
71 6
    public function getUnicodeLanguageIdentifier(): ?string
72
    {
73 6
        if (null === $this->unicodeLanguageIdentifier) {
74 6
            return UnicodeLanguageIdentifierFieldInterface::DEFAULT_UNICODE_LANGUAGE_IDENTIFIER;
75
        }
76
77 6
        return $this->unicodeLanguageIdentifier;
78
    }
79
80
    /**
81
     * @param string|null $unicodeLanguageIdentifier
82
     *
83
     * @return self
84
     */
85 6
    private function setUnicodeLanguageIdentifier(?string $unicodeLanguageIdentifier): self
86
    {
87 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

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