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 (#152)
by joseph
15:36
created

metaForTemplateEntities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 19
nc 1
nop 1
dl 0
loc 25
rs 9.6333
c 0
b 0
f 0
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 TemplateNamespace\Entities\TemplateEntity as TemplateEntity;
8
use TemplateNamespace\Entity\Relations\TemplateEntity\Traits\HasRequiredTemplateEntitiesAbstract;
9
use TemplateNamespace\Entity\Relations\TemplateEntity\Traits\ReciprocatesTemplateEntity;
10
11
/**
12
 * Trait HasRequiredTemplateEntitiesInverseManyToMany
13
 *
14
 * The inverse side of a Many to Many relationship between the Current Entity
15
 * And TemplateEntity
16
 *
17
 * @see     https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#owning-and-inverse-side-on-a-manytomany-association
18
 *
19
 * @package TemplateNamespace\Entity\Relations\TemplateEntity\Traits\HasRequiredTemplateEntities
20
 */
21
// phpcs:enable
22
trait HasRequiredTemplateEntitiesInverseManyToMany
23
{
24
    use HasRequiredTemplateEntitiesAbstract;
25
26
    use ReciprocatesTemplateEntity;
27
28
    /**
29
     * @param ClassMetadataBuilder $builder
30
     *
31
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
32
     * @throws \ReflectionException
33
     * @SuppressWarnings(PHPMD.StaticAccess)
34
     */
35
    public static function metaForTemplateEntities(
36
        ClassMetadataBuilder $builder
37
    ): void {
38
        $manyToManyBuilder = $builder->createManyToMany(
39
            TemplateEntity::getDoctrineStaticMeta()->getPlural(),
40
            TemplateEntity::class
41
        );
42
        $manyToManyBuilder->mappedBy(self::getDoctrineStaticMeta()->getPlural());
43
        $fromTableName = Inflector::tableize(TemplateEntity::getDoctrineStaticMeta()->getPlural());
44
        $toTableName   = Inflector::tableize(self::getDoctrineStaticMeta()->getPlural());
45
        $manyToManyBuilder->setJoinTable($fromTableName . '_to_' . $toTableName);
46
        $manyToManyBuilder->addJoinColumn(
47
            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...
48
            static::PROP_ID,
49
            true
50
        );
51
        $manyToManyBuilder->addInverseJoinColumn(
52
            Inflector::tableize(
53
                TemplateEntity::getDoctrineStaticMeta()->getSingular()
54
            ) . '_' . TemplateEntity::PROP_ID,
55
            TemplateEntity::PROP_ID,
56
            true
57
        );
58
        $manyToManyBuilder->fetchExtraLazy();
59
        $manyToManyBuilder->build();
60
    }
61
}
62