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

LocaleFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 * @author    [email protected]
9
 */
10
11
namespace Core\I18n;
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 Core\I18n\Locale;
20
21
/**
22
 * Class ModuleOptionsFactory
23
 * @package Core\I18n
24
 */
25
class LocaleFactory 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
        /* @var \Core\Options\ModuleOptions $options*/
43
        $options = $container->get('Core/Options');
44
        return new Locale($options->getSupportedLanguages());
45
    }
46
47
48
    /**
49
     * {@inheritDoc}
50
     *
51
     * @param ServiceLocatorInterface $serviceLocator
52
     * @return ModuleOptions
53
     */
54
    public function createService(ServiceLocatorInterface $serviceLocator)
55
    {
56
        return $this($serviceLocator, Locale::class);
57
    }
58
}
59