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 ( 51c99d...a4bf8a )
by joseph
24s queued 11s
created

LocaleIdentifierFieldTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 81
rs 10
c 0
b 0
f 0
ccs 22
cts 22
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getLocaleIdentifier() 0 7 2
A validatorMetaForLocaleIdentifier() 0 2 1
A metaForLocaleIdentifier() 0 18 1
A setLocaleIdentifier() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
4
5
// phpcs:disable
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\LocaleIdentifierFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\ValidatedEntityInterface;
12
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
13
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
14
15
// phpcs:enable
16
trait LocaleIdentifierFieldTrait
17
{
18
19
    /**
20
     * @var string|null
21
     */
22
    private $localeIdentifier;
23
24
    /**
25
     * @SuppressWarnings(PHPMD.StaticAccess)
26
     * @param ClassMetadataBuilder $builder
27
     */
28 1
    public static function metaForLocaleIdentifier(ClassMetadataBuilder $builder): void
29
    {
30 1
        $fieldBuilder = new FieldBuilder(
31 1
            $builder,
32
            [
33 1
                'fieldName' => LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER,
34
                'type'      => Type::STRING,
35
                'default'   => LocaleIdentifierFieldInterface::DEFAULT_LOCALE_IDENTIFIER,
36
            ]
37
        );
38
        $fieldBuilder
39 1
            ->columnName(
40 1
                MappingHelper::getColumnNameForField(LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER)
41
            )
42 1
            ->nullable(LocaleIdentifierFieldInterface::DEFAULT_LOCALE_IDENTIFIER === null)
43 1
            ->unique(false)
44 1
            ->length(50)
45 1
            ->build();
46 1
    }
47
48
    /**
49
     * This method sets the validation for this field.
50
     *
51
     * You should add in as many relevant property constraints as you see fit.
52
     *
53
     * Remove the PHPMD suppressed warning once you start setting constraints
54
     *
55
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
56
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
57
     *
58
     * @param ValidatorClassMetaData $metadata
59
     *
60
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
61
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
62
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
63
     */
64 2
    protected static function validatorMetaForLocaleIdentifier(ValidatorClassMetaData $metadata)
0 ignored issues
show
Unused Code introduced by
The parameter $metadata is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
    protected static function validatorMetaForLocaleIdentifier(/** @scrutinizer ignore-unused */ ValidatorClassMetaData $metadata)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
    {
66
        //        $metadata->addPropertyConstraint(
67
        //            LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER,
68
        //            new NotBlank()
69
        //        );
70 2
    }
71
72
    /**
73
     * @return string|null
74
     */
75 2
    public function getLocaleIdentifier(): ?string
76
    {
77 2
        if (null === $this->localeIdentifier) {
78 1
            return LocaleIdentifierFieldInterface::DEFAULT_LOCALE_IDENTIFIER;
79
        }
80
81 2
        return $this->localeIdentifier;
82
    }
83
84
    /**
85
     * @param string|null $localeIdentifier
86
     *
87
     * @return self
88
     */
89 2
    public function setLocaleIdentifier(?string $localeIdentifier): self
90
    {
91 2
        $this->localeIdentifier = $localeIdentifier;
92 2
        if ($this instanceof ValidatedEntityInterface) {
93 2
            $this->validateProperty(LocaleIdentifierFieldInterface::PROP_LOCALE_IDENTIFIER);
94
        }
95
96 2
        return $this;
97
    }
98
}
99