ModuleOptionsFactory::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 4
nc 4
nop 3
1
<?php
2
3
namespace JwPersistentUser\Model;
4
5
use Zend\ServiceManager\FactoryInterface;
6
use Zend\ServiceManager\ServiceLocatorInterface;
7
use Interop\Container\ContainerInterface;
8
9
class ModuleOptionsFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\FactoryInterface has been deprecated with message: Use Zend\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
10
{
11
    const KEY = 'jwpersistentuser';
12
13
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
14
    {
15
        $options = new ModuleOptions;
16
17
        $config = $container->get('Config');
18
        if (isset($config[self::KEY]) && is_array($config[self::KEY])) {
19
            $options->setFromArray($config[self::KEY]);
20
        }
21
22
        if (!$options->getSerieTokenEntityClass()) {
23
            $options->setSerieTokenEntityClass('JwPersistentUser\Model\SerieToken');
24
        }
25
26
        return $options;
27
    }
28
29
    public function createService(ServiceLocatorInterface $serviceLocator)
30
    {
31
        return $this($serviceLocator->getServiceLocator(), 'JwPersistentUser\Service\Cookie');
32
    }
33
}
34