Completed
Push — develop ( 49270f...975a05 )
by
unknown
06:55
created

ModuleOptionsFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @author [email protected]
8
 * @license   MIT
9
 */
10
11
namespace Applications\Factory;
12
13
use Interop\Container\ContainerInterface;
14
use Interop\Container\Exception\ContainerException;
15
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
16
use Zend\ServiceManager\Exception\ServiceNotFoundException;
17
use Zend\ServiceManager\FactoryInterface;
18
use Zend\ServiceManager\ServiceLocatorInterface;
19
use Applications\Options\ModuleOptions;
20
21
/**
22
 * Creates an instance of options for applications
23
 */
24 View Code Duplication
class ModuleOptionsFactory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
    /**
27
     * Create a ModuleOptions options
28
     *
29
     * @param  ContainerInterface $container
30
     * @param  string             $requestedName
31
     * @param  null|array         $options
32
     *
33
     * @return ModuleOptions
34
     * @throws ServiceNotFoundException if unable to resolve the service.
35
     * @throws ServiceNotCreatedException if an exception is raised when
36
     *     creating a service.
37
     * @throws ContainerException if any other error occurs
38
     */
39
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
40
    {
41
        $config = $container->get('Config');
42
        return new ModuleOptions(isset($config['application_options']) ? $config['application_options'] : array());
43
    }
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public function createService(ServiceLocatorInterface $serviceLocator)
48
    {
49
        return $this($serviceLocator, ModuleOptions::class);
50
    }
51
}
52