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

DoctrineReflectionFactoryFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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