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 (#51)
by joseph
102:38 queued 99:24
created

DeactivatedDateFieldTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 41.18%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 56
c 0
b 0
f 0
ccs 7
cts 17
cp 0.4118
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A metaForDeactivatedDate() 0 5 1
A setDeactivatedDate() 0 8 2
A getDeactivatedDate() 0 3 1
A validatorMetaForDeactivatedDate() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\Date;
4
5
// phpcs:disable
6
7
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Date\DeactivatedDateFieldInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
10
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\ValidatedEntityInterface;
11
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
12
use Symfony\Component\Validator\Constraints\DateTime;
13
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
14
15
// phpcs:enable
16
trait DeactivatedDateFieldTrait
17
{
18
19
    /**
20
     * @var \DateTime|null
21
     */
22
    private $deactivatedDate;
23
24
    /**
25
     * @SuppressWarnings(PHPMD.StaticAccess)
26
     * @param ClassMetadataBuilder $builder
27
     */
28
    public static function metaForDeactivatedDate(ClassMetadataBuilder $builder): void
29
    {
30
        MappingHelper::setSimpleDatetimeFields(
31
            [DeactivatedDateFieldInterface::PROP_DEACTIVATED_DATE],
32
            $builder
33
        );
34
    }
35
36
    /**
37
     * @param ValidatorClassMetaData $metadata
38
     *
39
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
40
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
41
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
42
     */
43
    protected static function validatorMetaForDeactivatedDate(ValidatorClassMetaData $metadata): void
44
    {
45
        $metadata->addPropertyConstraint(
46
            DeactivatedDateFieldInterface::PROP_DEACTIVATED_DATE,
47
            new DateTime()
48
        );
49
    }
50
51
    /**
52
     * @return \DateTime|null
53
     */
54 1
    public function getDeactivatedDate(): ?\DateTime
55
    {
56 1
        return $this->deactivatedDate;
57
    }
58
59
    /**
60
     * @param \DateTime|null $deactivatedDate
61
     *
62
     * @return $this|DeactivatedDateFieldInterface
63
     */
64 1
    public function setDeactivatedDate(?\DateTime $deactivatedDate): self
65
    {
66 1
        $this->deactivatedDate = $deactivatedDate;
67 1
        if ($this instanceof ValidatedEntityInterface) {
68 1
            $this->validateProperty(DeactivatedDateFieldInterface::PROP_DEACTIVATED_DATE);
69
        }
70
71 1
        return $this;
72
    }
73
}
74