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 (#154)
by Ross
22:04
created

DomainNameFieldTrait::initDomainName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 3
cp 0.6667
crap 1.037
rs 10
c 0
b 0
f 0
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\DomainName;
10
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
11
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
12
13
// phpcs:enable
14
trait DomainNameFieldTrait
15
{
16
17
    /**
18
     * @var string|null
19
     */
20
    private $domainName;
21
22
    /**
23
     * @SuppressWarnings(PHPMD.StaticAccess)
24
     * @param ClassMetadataBuilder $builder
25
     */
26 5
    public static function metaForDomainName(ClassMetadataBuilder $builder): void
27
    {
28 5
        MappingHelper::setSimpleStringFields(
29 5
            [DomainNameFieldInterface::PROP_DOMAIN_NAME],
30 5
            $builder,
31 5
            DomainNameFieldInterface::DEFAULT_DOMAIN_NAME,
32 5
            false
33
        );
34 5
    }
35
36
    /**
37
     * Use a custom validator to call filter_var to validate that the domain name is valid
38
     *
39
     * @param ValidatorClassMetaData $metadata
40
     */
41 5
    protected static function validatorMetaForPropertyDomainName(ValidatorClassMetaData $metadata): void
42
    {
43 5
        $metadata->addPropertyConstraint(
44 5
            DomainNameFieldInterface::PROP_DOMAIN_NAME,
45 5
            new DomainName()
46
        );
47 5
    }
48
49
    /**
50
     * @return string|null
51
     */
52 5
    public function getDomainName(): ?string
53
    {
54 5
        if (null === $this->domainName) {
55 5
            return DomainNameFieldInterface::DEFAULT_DOMAIN_NAME;
56
        }
57
58 5
        return $this->domainName;
59
    }
60
61
    /**
62
     * @param string|null $domainName
63
     *
64
     * @return self
65
     */
66 5
    private function setDomainName(?string $domainName): self
67
    {
68 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

68
        $this->/** @scrutinizer ignore-call */ 
69
               updatePropertyValue(
Loading history...
69 5
            DomainNameFieldInterface::PROP_DOMAIN_NAME,
70 5
            $domainName
71
        );
72
73 5
        return $this;
74
    }
75
76 5
    private function initDomainName()
77
    {
78 5
        $this->domainName = DomainNameFieldInterface::DEFAULT_DOMAIN_NAME;
79 5
    }
80
}
81