Test Failed
Push — master ( 25b8d1...f70cb8 )
by Pavel
03:49
created

DoctrineReflectionFactory::createObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Adaptors\Doctrine;
4
5
use Doctrine\Bundle\DoctrineBundle\Registry;
6
use ScayTrase\Api\Cruds\Factory\ReflectionConstructorFactory;
7
use ScayTrase\Api\Cruds\ObjectFactoryInterface;
8
9
final class DoctrineReflectionFactory implements ObjectFactoryInterface
10
{
11
    /** @var  ObjectFactoryInterface */
12
    private $factory;
13
14
    /**
15
     * DoctrineReflectionFactory constructor.
16
     *
17
     * @param Registry $registry
18
     * @param string   $class
19
     * @param array    $args
20
     */
21
    public function __construct(Registry $registry, $class, array $args)
22
    {
23
        $this->factory = new ReflectionConstructorFactory(
24
            $registry->getManagerForClass($class)->getClassMetadata($class)->getName(),
25
            $args
26
        );
27
    }
28
29
    /** {@inheritdoc} */
30
    public function createObject($data)
31
    {
32
        return $this->factory->createObject($data);
33
    }
34
}
35