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 ( 0d82f1...4042bf )
by joseph
20s queued 14s
created

dsmInitRequiredRelationForTemplateEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
rs 10
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 EdmondsCommerce\DoctrineStaticMeta\DoctrineStaticMeta;
7
use Symfony\Component\Validator\Constraints\NotBlank;
8
use Symfony\Component\Validator\Constraints\Valid;
9
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
10
use Symfony\Component\Validator\Exception\InvalidOptionsException;
11
use Symfony\Component\Validator\Exception\MissingOptionsException;
12
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
13
use TemplateNamespace\Entity\Interfaces\TemplateEntityInterface;
14
use TemplateNamespace\Entity\Relations\TemplateEntity\Interfaces\HasRequiredTemplateEntityInterface;
15
use TemplateNamespace\Entity\Relations\TemplateEntity\Interfaces\ReciprocatesTemplateEntityInterface;
16
17
/**
18
 * The base trait for required relations to a single TemplateEntity
19
 */
20
// phpcs:enable
21
trait HasRequiredTemplateEntityAbstract
22
{
23
    /**
24
     * @var TemplateEntityInterface
25
     */
26
    private $templateEntity;
27
28
    /**
29
     * @param ClassMetadataBuilder $builder
30
     *
31
     * @return void
32
     */
33
    abstract public static function metaForTemplateEntity(
34
        ClassMetadataBuilder $builder
35
    ): void;
36
37
    /**
38
     * @param ValidatorClassMetaData $metadata
39
     *
40
     * @throws MissingOptionsException
41
     * @throws InvalidOptionsException
42
     * @throws ConstraintDefinitionException
43
     */
44
    public static function validatorMetaForPropertyTemplateEntity(
45
        ValidatorClassMetaData $metadata
46
    ): void {
47
        $validConstraint           = new Valid();
48
        $validConstraint->traverse = false;
49
        $metadata->addPropertyConstraint(
50
            HasRequiredTemplateEntityInterface::PROPERTY_NAME_TEMPLATE_ENTITY,
51
            new NotBlank()
52
        );
53
        $metadata->addPropertyConstraint(
54
            HasRequiredTemplateEntityInterface::PROPERTY_NAME_TEMPLATE_ENTITY,
55
            $validConstraint
56
        );
57
    }
58
59
    private static function dsmInitRequiredRelationForTemplateEntity(DoctrineStaticMeta $dsm): void
60
    {
61
        $dsm->setRequiredRelationProperty(
62
            new DoctrineStaticMeta\RequiredRelation(
63
                HasRequiredTemplateEntityInterface::PROPERTY_NAME_TEMPLATE_ENTITY,
64
                TemplateEntityInterface::class,
65
                false
66
            )
67
        );
68
    }
69
70
    /**
71
     * @return TemplateEntityInterface
72
     */
73
    public function getTemplateEntity(): TemplateEntityInterface
74
    {
75
        return $this->templateEntity;
76
    }
77
78
    /**
79
     * @param TemplateEntityInterface $templateEntity
80
     * @param bool                    $recip
81
     *
82
     * @return $this
83
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
84
     */
85
    public function setTemplateEntity(
86
        TemplateEntityInterface $templateEntity,
87
        bool $recip = true
88
    ): self {
89
90
        $this->setEntityAndNotify('templateEntity', $templateEntity);
0 ignored issues
show
Bug introduced by
It seems like setEntityAndNotify() 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

90
        $this->/** @scrutinizer ignore-call */ 
91
               setEntityAndNotify('templateEntity', $templateEntity);
Loading history...
91
        if (
92
            $this instanceof ReciprocatesTemplateEntityInterface
93
            && true === $recip
94
        ) {
95
            $this->reciprocateRelationOnTemplateEntity($templateEntity);
96
        }
97
98
        return $this;
99
    }
100
}
101