Completed
Push — master ( 06e52a...98c39c )
by Pavel
13:39 queued 10:37
created

DoctrineReflectionFactoryFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 7 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Adaptors\DoctrineOrm;
4
5
use Doctrine\Common\Persistence\ManagerRegistry;
6
use ScayTrase\Api\Cruds\EntityFactoryInterface;
7
use ScayTrase\Api\Cruds\ReflectionConstructorFactory;
8
9
final class DoctrineReflectionFactoryFactory
10
{
11
    /** @var  ManagerRegistry */
12
    private $registry;
13
14
    /**
15
     * @param ManagerRegistry $registry
16
     */
17
    public function __construct(ManagerRegistry $registry)
18
    {
19
        $this->registry = $registry;
20
    }
21
22
    /**
23
     * @param string $class
24
     * @param array  $args
25
     *
26
     * @return EntityFactoryInterface
27
     */
28
    public function create($class, array $args)
29
    {
30
        return new ReflectionConstructorFactory(
31
            $this->registry->getManagerForClass($class)->getClassMetadata($class)->getName(),
32
            $args
33
        );
34
    }
35
}
36