DataMapperAdapterFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 25
wmc 1
lcom 0
cbo 3
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 15 1
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\OAuth2\Factory;
9
10
use Thorr\OAuth2\Options\ModuleOptions;
11
use Thorr\OAuth2\Storage\DataMapperAdapter;
12
use Thorr\Persistence\DataMapper\Manager\DataMapperManager;
13
use Zend\ServiceManager\FactoryInterface;
14
use Zend\ServiceManager\ServiceLocatorInterface;
15
16
class DataMapperAdapterFactory implements FactoryInterface
17
{
18
    /**
19
     * Create service
20
     *
21
     * @param ServiceLocatorInterface $serviceLocator
22
     *
23
     * @return DataMapperAdapter
24
     */
25
    public function createService(ServiceLocatorInterface $serviceLocator)
26
    {
27
        /** @var DataMapperManager $dataMapperManager */
28
        $dataMapperManager = $serviceLocator->get(DataMapperManager::class);
29
30
        $password = $serviceLocator->get('Thorr\OAuth2\DefaultPasswordInterface');
31
32
        /** @var ModuleOptions $moduleOptions */
33
        $moduleOptions = $serviceLocator->get(ModuleOptions::class);
34
35
        $adapter = new DataMapperAdapter($dataMapperManager, $password);
36
        $adapter->setUserClass($moduleOptions->getUserEntityClassName());
37
38
        return $adapter;
39
    }
40
}
41