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

EmailAddressFieldTrait::getEmailAddress()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 6
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
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\EmailAddressFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
10
use EdmondsCommerce\DoctrineStaticMeta\Schema\Database;
11
use Symfony\Component\Validator\Constraints\Email;
12
use Symfony\Component\Validator\Constraints\Length;
13
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
14
use Symfony\Component\Validator\Exception\InvalidOptionsException;
15
use Symfony\Component\Validator\Exception\MissingOptionsException;
16
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
17
18
trait EmailAddressFieldTrait
19
{
20
21
    /**
22
     * @var string|null
23
     */
24
    private $emailAddress;
25
26
    /**
27
     * @SuppressWarnings(PHPMD.StaticAccess)
28
     * @param ClassMetadataBuilder $builder
29
     */
30
    public static function metaForEmailAddress(ClassMetadataBuilder $builder): void
31
    {
32
        MappingHelper::setSimpleStringFields(
33
            [EmailAddressFieldInterface::PROP_EMAIL_ADDRESS],
34
            $builder,
35
            EmailAddressFieldInterface::DEFAULT_EMAIL_ADDRESS,
36
            true
37
        );
38
    }
39
40
    /**
41
     * This method sets the validation for this field.
42
     *
43
     * You should add in as many relevant property constraints as you see fit.
44
     *
45
     * @see https://symfony.com/doc/current/validation.html#supported-constraints
46
     *
47
     * @param ValidatorClassMetaData $metadata
48
     *
49
     * @throws MissingOptionsException
50
     * @throws InvalidOptionsException
51
     * @throws ConstraintDefinitionException
52
     */
53
    protected static function validatorMetaForPropertyEmailAddress(ValidatorClassMetaData $metadata): void
54
    {
55
        $metadata->addPropertyConstraints(
56
            EmailAddressFieldInterface::PROP_EMAIL_ADDRESS,
57
            [
58
                new Email(),
59
                new Length(
60
                    [
61
                        'min' => 0,
62
                        'max' => Database::MAX_VARCHAR_LENGTH,
63
                    ]
64
                ),
65
            ]
66
        );
67
    }
68
69
    /**
70
     * @return string|null
71
     */
72
    public function getEmailAddress(): ?string
73
    {
74
        if (null === $this->emailAddress) {
75
            return EmailAddressFieldInterface::DEFAULT_EMAIL_ADDRESS;
76
        }
77
78
        return $this->emailAddress;
79
    }
80
81
    /**
82
     * @param string|null $emailAddress
83
     *
84
     * @return self
85
     */
86
    private function setEmailAddress(?string $emailAddress): self
87
    {
88
        $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

88
        $this->/** @scrutinizer ignore-call */ 
89
               updatePropertyValue(
Loading history...
89
            EmailAddressFieldInterface::PROP_EMAIL_ADDRESS,
90
            $emailAddress
91
        );
92
93
        return $this;
94
    }
95
}
96