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.
Passed
Pull Request — master (#47)
by joseph
02:29
created

CompletedDateFieldTrait::metaForCompletedDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 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\Interfaces\EntityInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\ValidatedEntityInterface;
10
use \EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
11
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Date\CompletedDateFieldInterface;
12
use Symfony\Component\Validator\Constraints\DateTime;
13
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
14
15
// phpcs:enable
16
trait CompletedDateFieldTrait
17
{
18
19
    /**
20
     * @var \DateTime|null
21
     */
22
    private $completedDate;
23
24
    /**
25
     * @SuppressWarnings(PHPMD.StaticAccess)
26
     * @param ClassMetadataBuilder $builder
27
     */
28
    public static function metaForCompletedDate(ClassMetadataBuilder $builder): void
29
    {
30
        MappingHelper::setSimpleDatetimeFields(
31
            [CompletedDateFieldInterface::PROP_COMPLETED_DATE],
32
            $builder,
33
            true
34
        );
35
    }
36
37
    /**
38
     * @param ValidatorClassMetaData $metadata
39
     *
40
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
41
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
42
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
43
     */
44
    protected static function validatorMetaForCompletedDate(ValidatorClassMetaData $metadata): void
45
    {
46
        $metadata->addPropertyConstraint(
47
            CompletedDateFieldInterface::PROP_COMPLETED_DATE,
48
            new DateTime()
49
        );
50
    }
51
52
    /**
53
     * @return \DateTime|null
54
     */
55
    public function getCompletedDate(): ?\DateTime
56
    {
57
        return $this->completedDate;
58
    }
59
60
    /**
61
     * @param \DateTime|null $completedDate
62
     * @return $this|CompletedDateFieldInterface
63
     */
64
    public function setCompletedDate(?\DateTime $completedDate): self
65
    {
66
        $this->completedDate = $completedDate;
67
        if ($this instanceof ValidatedEntityInterface) {
68
            $this->validateProperty(CompletedDateFieldInterface::PROP_COMPLETED_DATE);
69
        }
70
        return $this;
71
    }
72
}
73