Completed
Push — master ( 0004c8...3efb43 )
by Андрей
04:54 queued 02:11
created

EntityAbstractFactory::canCreateServiceWithName()   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 3
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\Doctrine\EntityManager;
7
8
use Zend\ServiceManager\AbstractFactoryInterface;
9
use Zend\ServiceManager\ServiceLocatorInterface;
10
use ReflectionClass;
11
12
/**
13
 * Class EntityAbstractFactory
14
 *
15
 * @package Nnx\Doctrine\EntityManager
16
 */
17
class EntityAbstractFactory implements AbstractFactoryInterface
18
{
19
    /**
20
     * @inheritdoc
21
     *
22
     * @param ServiceLocatorInterface $serviceLocator
23
     * @param                         $name
24
     * @param                         $requestedName
25
     *
26
     * @return boolean
27
     */
28
    public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
29
    {
30
        return class_exists($requestedName);
31
    }
32
33
34
    /**
35
     * @inheritdoc
36
     *
37
     * @param ServiceLocatorInterface $serviceLocator
38
     * @param                         $name
39
     * @param                         $requestedName
40
     *
41
     * @return mixed
42
     */
43
    public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
44
    {
45
        $r = new ReflectionClass($requestedName);
46
        return $r->newInstance();
47
    }
48
}
49