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.

HasRequiredTemplateEntitiesInverseManyToMany   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A metaForTemplateEntities() 0 25 1
1
<?php declare(strict_types=1);
2
// phpcs:disable
3
namespace TemplateNamespace\Entity\Relations\TemplateEntity\Traits\HasRequiredTemplateEntities;
4
5
use Doctrine\Common\Inflector\Inflector;
6
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
7
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
8
use ReflectionException;
9
use TemplateNamespace\Entities\TemplateEntity as TemplateEntity;
10
use TemplateNamespace\Entity\Relations\TemplateEntity\Traits\HasRequiredTemplateEntitiesAbstract;
11
use TemplateNamespace\Entity\Relations\TemplateEntity\Traits\ReciprocatesTemplateEntity;
12
13
/**
14
 * Trait HasRequiredTemplateEntitiesInverseManyToMany
15
 *
16
 * The inverse side of a Many to Many relationship between the Current Entity
17
 * And TemplateEntity
18
 *
19
 * @see     https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#owning-and-inverse-side-on-a-manytomany-association
20
 *
21
 * @package TemplateNamespace\Entity\Relations\TemplateEntity\Traits\HasRequiredTemplateEntities
22
 */
23
// phpcs:enable
24
trait HasRequiredTemplateEntitiesInverseManyToMany
25
{
26
    use HasRequiredTemplateEntitiesAbstract;
27
28
    use ReciprocatesTemplateEntity;
29
30
    /**
31
     * @param ClassMetadataBuilder $builder
32
     *
33
     * @throws DoctrineStaticMetaException
34
     * @throws ReflectionException
35
     * @SuppressWarnings(PHPMD.StaticAccess)
36
     */
37
    public static function metaForTemplateEntities(
38
        ClassMetadataBuilder $builder
39
    ): void {
40
        $manyToManyBuilder = $builder->createManyToMany(
41
            TemplateEntity::getDoctrineStaticMeta()->getPlural(),
42
            TemplateEntity::class
43
        );
44
        $manyToManyBuilder->mappedBy(self::getDoctrineStaticMeta()->getPlural());
45
        $fromTableName = Inflector::tableize(TemplateEntity::getDoctrineStaticMeta()->getPlural());
46
        $toTableName   = Inflector::tableize(self::getDoctrineStaticMeta()->getPlural());
47
        $manyToManyBuilder->setJoinTable($fromTableName . '_to_' . $toTableName);
48
        $manyToManyBuilder->addJoinColumn(
49
            Inflector::tableize(self::getDoctrineStaticMeta()->getSingular() . '_' . static::PROP_ID),
0 ignored issues
show
Bug introduced by
The constant TemplateNamespace\Entity...erseManyToMany::PROP_ID was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
50
            static::PROP_ID,
51
            true
52
        );
53
        $manyToManyBuilder->addInverseJoinColumn(
54
            Inflector::tableize(
55
                TemplateEntity::getDoctrineStaticMeta()->getSingular()
56
            ) . '_' . TemplateEntity::PROP_ID,
57
            TemplateEntity::PROP_ID,
58
            true
59
        );
60
        $manyToManyBuilder->fetchExtraLazy();
61
        $manyToManyBuilder->build();
62
    }
63
}
64