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 ( 2a6b46...0d82f1 )
by joseph
20s queued 14s
created

validatorMetaForPropertyDomainName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String;
6
7
// phpcs:disable Generic.Files.LineLength.TooLong
8
9
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
10
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\DomainNameFieldInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\Entity\Validation\Constraints\FieldConstraints\DomainName;
12
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
13
use EdmondsCommerce\DoctrineStaticMeta\Schema\Database;
14
use Symfony\Component\Validator\Constraints\Length;
15
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
16
17
// phpcs:enable
18
trait DomainNameFieldTrait
19
{
20
21
    /**
22
     * @var string|null
23
     */
24
    private $domainName;
25
26
    /**
27
     * @SuppressWarnings(PHPMD.StaticAccess)
28
     * @param ClassMetadataBuilder $builder
29
     */
30
    public static function metaForDomainName(ClassMetadataBuilder $builder): void
31
    {
32
        MappingHelper::setSimpleStringFields(
33
            [DomainNameFieldInterface::PROP_DOMAIN_NAME],
34
            $builder,
35
            DomainNameFieldInterface::DEFAULT_DOMAIN_NAME
36
        );
37
    }
38
39
    /**
40
     * Use a custom validator to call filter_var to validate that the domain name is valid
41
     *
42
     * @param ValidatorClassMetaData $metadata
43
     */
44
    protected static function validatorMetaForPropertyDomainName(ValidatorClassMetaData $metadata): void
45
    {
46
        $metadata->addPropertyConstraints(
47
            DomainNameFieldInterface::PROP_DOMAIN_NAME,
48
            [
49
                new DomainName(),
50
                new Length(
51
                    [
52
                        'min' => 0,
53
                        'max' => Database::MAX_VARCHAR_LENGTH,
54
                    ]
55
                ),
56
            ]
57
        );
58
    }
59
60
    /**
61
     * @return string|null
62
     */
63
    public function getDomainName(): ?string
64
    {
65
        if (null === $this->domainName) {
66
            return DomainNameFieldInterface::DEFAULT_DOMAIN_NAME;
67
        }
68
69
        return $this->domainName;
70
    }
71
72
    /**
73
     * @param string|null $domainName
74
     *
75
     * @return self
76
     */
77
    private function setDomainName(?string $domainName): self
78
    {
79
        $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

79
        $this->/** @scrutinizer ignore-call */ 
80
               updatePropertyValue(
Loading history...
80
            DomainNameFieldInterface::PROP_DOMAIN_NAME,
81
            $domainName
82
        );
83
84
        return $this;
85
    }
86
87
    private function initDomainName(): void
88
    {
89
        $this->domainName = DomainNameFieldInterface::DEFAULT_DOMAIN_NAME;
90
    }
91
}
92