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

newClassMetadataInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
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