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
Pull Request — master (#95)
by Ross
13:04 queued 10:08
created

ClassMetadataFactoryWithEntityFactories   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
eloc 16
dl 0
loc 48
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntityFactories() 0 3 1
A wakeupReflection() 0 5 2
A addEntityFactory() 0 3 1
A newClassMetadataInstance() 0 6 1
A setEntityManager() 0 4 1
A addGenericFactory() 0 3 1
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
10
class ClassMetadataFactoryWithEntityFactories extends ClassMetadataFactory implements EntityFactoryAware
11
{
12
    /** @var EntityFactoryInterface[] */
13
    public static $entityFactories = [];
14
    /** @var GenericFactoryInterface|null */
15
    public static $genericFactory;
16
17
    /** @var EntityManagerInterface */
18
    private $entityManager;
19
20
    public function setEntityManager(EntityManagerInterface $entityManager)
21
    {
22
        parent::setEntityManager($entityManager);
23
        $this->entityManager = $entityManager;
24
    }
25
26
    protected function newClassMetadataInstance($className): ClassMetadata
27
    {
28
        return new ClassMetadataWithEntityFactories(
29
            $className,
30
            $this->entityManager->getConfiguration()->getNamingStrategy(),
31
            $this->getEntityFactories()
32
        );
33
    }
34
35
    public function addEntityFactory(string $name, EntityFactoryInterface $entityFactory): void
36
    {
37
        self::$entityFactories[$name] = $entityFactory;
38
    }
39
40
    public function addGenericFactory(GenericFactoryInterface $genericFactory): void
41
    {
42
        self::$genericFactory = $genericFactory;
43
    }
44
45
    /**
46
     * @return EntityFactoryInterface[]
47
     */
48
    public function getEntityFactories(): array
49
    {
50
        return self::$entityFactories;
51
    }
52
53
    public function wakeupReflection(ClassMetadata $class, ReflectionService $reflectionService): void
54
    {
55
        parent::wakeupReflection($class, $reflectionService);
56
        if ($class instanceof ClassMetadataWithEntityFactories) {
57
            $class->setFactories(self::$entityFactories, self::$genericFactory);
58
        }
59
    }
60
}
61