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 ( 69b831...bd71a5 )
by joseph
20:49 queued 13s
created

DomainNameFieldTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 96%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 72
ccs 24
cts 25
cp 0.96
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

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

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