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

ClassMetadataWithEntityFactories   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 35
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setFactories() 0 4 1
A __construct() 0 9 1
A newInstance() 0 11 3
1
<?php
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\EntityManager\Mapping;
4
5
use Doctrine\ORM\Mapping\ClassMetadata;
6
use Doctrine\ORM\Mapping\NamingStrategy;
7
8
class ClassMetadataWithEntityFactories extends ClassMetadata
9
{
10
    /** @var EntityFactoryInterface[] */
11
    private $entityFactories;
12
    /** @var GenericFactoryInterface|null */
13
    private $genericFactory;
14
15
    public function __construct(
16
        $entityName,
17
        NamingStrategy $namingStrategy = null,
18
        array $entityFactories = [],
19
        GenericFactoryInterface $genericFactory = null
20
    ) {
21
        parent::__construct($entityName, $namingStrategy);
22
        $this->entityFactories = $entityFactories;
23
        $this->genericFactory  = $genericFactory;
24
    }
25
26
    public function newInstance()
27
    {
28
        if (isset($this->entityFactories[$this->name])) {
29
            return $this->entityFactories[$this->name]->getEntity();
30
        }
31
32
        if ($this->genericFactory !== null) {
33
            return $this->genericFactory->getEntity($this->name);
34
        }
35
36
        return parent::newInstance();
37
    }
38
39
    public function setFactories(array $entityFactories, GenericFactoryInterface $genericFactory = null)
40
    {
41
        $this->entityFactories = $entityFactories;
42
        $this->genericFactory  = $genericFactory;
43
    }
44
}
45