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

EmailAddressFieldTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 95.83%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 76
ccs 23
cts 24
cp 0.9583
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

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

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