Completed
Push — next ( 191339...0efc14 )
by Mathias
10:05
created

DataTransformerFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
ccs 10
cts 10
cp 1
cc 1
eloc 11
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 * YAWIK Stackoverflow API
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2016 - 2017 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace StackoverflowApi\Factory\Client;
12
13
use Interop\Container\ContainerInterface;
14
use StackoverflowApi\Client\DataTransformer;
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
/**
19
 * Factory for \StackoverflowApi\Client\DataTransformer
20
 * 
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @since 0.1.0
23
 */
24
class DataTransformerFactory implements FactoryInterface
25
{
26
    /**
27
     * Create a DataTransformer
28
     *
29
     * @param ContainerInterface $container
30
     * @param string             $requestedName
31
     * @param array              $options
32
     *
33
     * @return DataTransformer
34
     */
35 1
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
36
    {
37 1
        $viewHelperManager = $container->get('ViewHelperManager');
38 1
        $applyUrlHelper    = $viewHelperManager->get('ApplyUrl');
39 1
        $serverUrlHelper   = $viewHelperManager->get('ServerUrl');
40 1
        $orgImageManager   = $container->get('Organizations\ImageFileCache\Manager');
41 1
        $transformer       = new DataTransformer();
42
43
        $transformer
44 1
            ->setApplyUrlHelper($applyUrlHelper)
45 1
            ->setServerUrlHelper($serverUrlHelper)
46 1
            ->setOrganizationImageManager($orgImageManager)
47
        ;
48
49 1
        return $transformer;
50
    }
51
52
    /**
53
     * Create service
54
     *
55
     * @param ServiceLocatorInterface $serviceLocator
56
     *
57
     * @return DataTransformer
58
     */
59 1
    public function createService(ServiceLocatorInterface $serviceLocator)
60
    {
61 1
        return $this($serviceLocator, DataTransformer::class);
62
    }
63
}