User::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace LmcUser\Factory\Mapper;
4
5
use Interop\Container\ContainerInterface;
6
use Laminas\ServiceManager\Factory\FactoryInterface;
7
use LmcUser\Mapper;
8
use LmcUser\Options\ModuleOptions;
9
10
class User implements FactoryInterface
11
{
12
    /**
13
     * {@inheritDoc}
14
     * @see \Laminas\ServiceManager\Factory\FactoryInterface::__invoke()
15
     */
16
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
17
    {
18
        /**
19
         * @var ModuleOptions $options
20
         */
21
        $options = $container->get('lmcuser_module_options');
22
        $dbAdapter = $container->get('lmcuser_laminas_db_adapter');
23
        $hydrator = $container->get('lmcuser_user_hydrator');
24
25
        $entityClass = $options->getUserEntityClass();
26
        $tableName = $options->getTableName();
27
28
        $mapper = new Mapper\User();
29
        $mapper->setDbAdapter($dbAdapter);
30
        $mapper->setTableName($tableName);
31
        $mapper->setEntityPrototype(new $entityClass);
32
        $mapper->setHydrator($hydrator);
33
34
        return $mapper;
35
    }
36
}
37