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.

addEntityFactory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\EntityManager\Mapping;
4
5
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
6
use Doctrine\Common\Persistence\Mapping\ReflectionService;
7
use Doctrine\ORM\EntityManagerInterface;
8
use Doctrine\ORM\Mapping\ClassMetadataFactory;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Factory\EntityFactoryInterface as GenericEntityFactoryInterface;
10
11
class ClassMetadataFactoryWithEntityFactories extends ClassMetadataFactory implements EntityFactoryAware
12
{
13
    /** @var EntityFactoryInterface[] */
14
    public static $entityFactories = [];
15
    /** @var GenericEntityFactoryInterface|null */
16
    public static $genericFactory;
17
18
    /** @var EntityManagerInterface */
19
    private $entityManager;
20
21
    public function setEntityManager(EntityManagerInterface $entityManager)
22
    {
23
        parent::setEntityManager($entityManager);
24
        $this->entityManager = $entityManager;
25
    }
26
27
    public function addEntityFactory(string $name, EntityFactoryInterface $entityFactory): void
28
    {
29
        self::$entityFactories[$name] = $entityFactory;
30
    }
31
32
    public function addGenericFactory(GenericEntityFactoryInterface $genericFactory): void
33
    {
34
        self::$genericFactory = $genericFactory;
35
    }
36
37
    public function wakeupReflection(ClassMetadata $class, ReflectionService $reflectionService): void
38
    {
39
        parent::wakeupReflection($class, $reflectionService);
40
        if ($class instanceof ClassMetadataWithEntityFactories) {
41
            $class->setFactories(self::$entityFactories, self::$genericFactory);
42
        }
43
    }
44
45
    protected function newClassMetadataInstance($className): ClassMetadata
46
    {
47
        return new ClassMetadataWithEntityFactories(
48
            $className,
49
            $this->entityManager->getConfiguration()->getNamingStrategy(),
50
            $this->getEntityFactories()
51
        );
52
    }
53
54
    /**
55
     * @return EntityFactoryInterface[]
56
     */
57
    public function getEntityFactories(): array
58
    {
59
        return self::$entityFactories;
60
    }
61
}
62