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

getPropertyValidatorMetaForTemplateEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
// phpcs:disable
3
namespace TemplateNamespace\Entity\Relations\TemplateEntity\Traits;
4
5
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
6
use Symfony\Component\Validator\Constraints\Valid;
7
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
8
use TemplateNamespace\Entities\TemplateEntity as TemplateEntity;
9
use TemplateNamespace\Entity\Relations\TemplateEntity\Interfaces\HasTemplateEntityInterface;
10
use TemplateNamespace\Entity\Relations\TemplateEntity\Interfaces\ReciprocatesTemplateEntityInterface;
11
12
/**
13
 * Trait HasTemplateEntityAbstract
14
 *
15
 * The base trait for relations to a single TemplateEntity
16
 *
17
 * @package TemplateNamespace\Entity\Relations\TemplateEntity\Traits
18
 */
19
// phpcs:enable
20
trait HasTemplateEntityAbstract
21
{
22
    /**
23
     * @var TemplateEntity|null
24
     */
25
    private $templateEntity;
26
27
    /**
28
     * @param ClassMetadataBuilder $builder
29
     *
30
     * @return void
31
     */
32
    abstract public static function metaForTemplateEntity(
33
        ClassMetadataBuilder $builder
34
    ): void;
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
    public static function validatorMetaForTemplateEntity(
44
        ValidatorClassMetaData $metadata
45
    ): void {
46
        $metadata->addPropertyConstraint(
47
            HasTemplateEntityInterface::PROPERTY_NAME_TEMPLATE_ENTITY,
48
            new Valid()
49
        );
50
    }
51
52
    /**
53
     * @return TemplateEntity|null
54
     */
55
    public function getTemplateEntity(): ?TemplateEntity
56
    {
57
        return $this->templateEntity;
58
    }
59
60
    /**
61
     * @param TemplateEntity|null $templateEntity
62
     * @param bool                $recip
63
     *
64
     * @return self
65
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
66
     */
67
    public function setTemplateEntity(
68
        ?TemplateEntity $templateEntity,
69
        bool $recip = true
70
    ): HasTemplateEntityInterface {
71
72
        $this->templateEntity = $templateEntity;
73
        if (
74
            $this instanceof ReciprocatesTemplateEntityInterface
75
            && true === $recip
76
            && null !== $templateEntity
77
        ) {
78
            $this->reciprocateRelationOnTemplateEntity($templateEntity);
79
        }
80
81
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type TemplateNamespace\Entity...sTemplateEntityAbstract which is incompatible with the type-hinted return TemplateNamespace\Entity...TemplateEntityInterface.
Loading history...
82
    }
83
84
    /**
85
     * @return self
86
     */
87
    public function removeTemplateEntity(): HasTemplateEntityInterface
88
    {
89
        $this->templateEntity = null;
90
91
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type TemplateNamespace\Entity...sTemplateEntityAbstract which is incompatible with the type-hinted return TemplateNamespace\Entity...TemplateEntityInterface.
Loading history...
92
    }
93
}
94