DataMapperAdapterFactory::createService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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