ModuleOptionsFactory::createService()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 4
nop 1
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw\Factory;
12
13
use WebinoDraw\Factory\InstructionsFactory;
14
use WebinoDraw\Options\ModuleOptions;
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
/**
19
 * Class ModuleOptionsFactory
20
 */
21
class ModuleOptionsFactory implements FactoryInterface
22
{
23
    /**
24
     * @param ServiceLocatorInterface $services
25
     * @return ModuleOptions
26
     */
27
    public function createService(ServiceLocatorInterface $services)
28
    {
29
        $config = $services->get('Config');
30
        $drawConfig = isset($config['webino_draw']) ? $config['webino_draw'] : [];
31
32
        if (array_key_exists('instructions', $drawConfig)) {
33
            $instructionsFactory = $services->get(InstructionsFactory::class);
34
            $drawConfig['instructions'] = $instructionsFactory->create($drawConfig['instructions']);
35
        }
36
37
        return new ModuleOptions($drawConfig);
38
    }
39
}
40