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
Pull Request — master (#138)
by joseph
96:08 queued 65:06
created

getUnicodeLanguageIdentifier()   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

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
cc 2
nc 2
nop 0
crap 2
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 1
    public static function metaForUnicodeLanguageIdentifier(ClassMetadataBuilder $builder): void
26
    {
27 1
        $fieldBuilder = new FieldBuilder(
28 1
            $builder,
29
            [
30 1
                'fieldName' => UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
31
                'type'      => Type::STRING,
32
                'default'   => null,
33
            ]
34
        );
35
        $fieldBuilder
36 1
            ->columnName(MappingHelper::getColumnNameForField(
37 1
                UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER
38
            ))
39 1
            ->nullable(true)
40 1
            ->unique(false)
41 1
            ->length(50)
42 1
            ->build();
43 1
    }
44
45
    /**
46
     * This method sets the validation for this field.
47
     *
48
     * You should add in as many relevant property constraints as you see fit.
49
     *
50
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
51
     *
52
     * @param ValidatorClassMetaData $metadata
53
     *
54
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
55
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
56
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
57
     */
58
    protected static function validatorMetaForUnicodeLanguageIdentifier(ValidatorClassMetaData $metadata): void
59
    {
60
        $metadata->addPropertyConstraint(
61
            UnicodeLanguageIdentifierFieldInterface::PROP_UNICODE_LANGUAGE_IDENTIFIER,
62
            new Language()
63
        );
64
    }
65
66
    /**
67
     * @return string|null
68
     */
69 2
    public function getUnicodeLanguageIdentifier(): ?string
70
    {
71 2
        if (null === $this->unicodeLanguageIdentifier) {
72 1
            return UnicodeLanguageIdentifierFieldInterface::DEFAULT_UNICODE_LANGUAGE_IDENTIFIER;
73
        }
74
75 2
        return $this->unicodeLanguageIdentifier;
76
    }
77
78
    /**
79
     * @param string|null $unicodeLanguageIdentifier
80
     *
81
     * @return self
82
     */
83 2
    public function setUnicodeLanguageIdentifier(?string $unicodeLanguageIdentifier): self
84
    {
85 2
        $this->updatePropertyValueThenValidateAndNotify(
0 ignored issues
show
Bug introduced by
It seems like updatePropertyValueThenValidateAndNotify() 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

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