Completed
Push — develop ( b8f7b1...cea6ad )
by
unknown
07:05
created

ModuleOptionsFactory::__invoke()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 4
nop 3
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @author cbleek
8
 * @license   AGPLv3
9
 */
10
11
namespace Jobs\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 Jobs\Options\ModuleOptions;
20
21
/**
22
 * Class ModuleOptionsFactory
23
 * @package Jobs\Factory
24
 */
25
class ModuleOptionsFactory implements FactoryInterface
26
{
27
    /**
28
     * Create an object
29
     *
30
     * @param  ContainerInterface $container
31
     * @param  string             $requestedName
32
     * @param  null|array         $options
33
     *
34
     * @return object
35
     * @throws ServiceNotFoundException if unable to resolve the service.
36
     * @throws ServiceNotCreatedException if an exception is raised when
37
     *     creating a service.
38
     * @throws ContainerException if any other error occurs
39
     */
40
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
41
    {
42
        $config = $container->get('Config');
43
44
        $jobs_options = isset($config['jobs_options']) ? $config['jobs_options'] : array();
0 ignored issues
show
Coding Style introduced by
$jobs_options does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
45
46
        if (!array_key_exists('multipostingApprovalMail', $jobs_options) || '' ==  trim($jobs_options['multipostingApprovalMail'])) {
0 ignored issues
show
Coding Style introduced by
$jobs_options does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
47
            $coreOptions = $container->get('Core/Options');
48
            $jobs_options['multipostingApprovalMail'] = $coreOptions->getSystemMessageEmail();
0 ignored issues
show
Coding Style introduced by
$jobs_options does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
49
        }
50
51
        return new ModuleOptions($jobs_options);
0 ignored issues
show
Coding Style introduced by
$jobs_options does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
52
    }
53
54
55
    /**
56
     * {@inheritDoc}
57
     *
58
     * @param ServiceLocatorInterface $serviceLocator
0 ignored issues
show
Bug introduced by
There is no parameter named $serviceLocator. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
59
     * @return ModuleOptions
60
     */
61
    public function createService(ServiceLocatorInterface $services)
62
    {
63
        return $this($services, ModuleOptions::class);
64
    }
65
}
66