TranslatorFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Acelaya\Website\Factory;
5
6
use Interop\Container\ContainerInterface;
7
use Interop\Container\Exception\ContainerException;
8
use Zend\I18n\Translator\Translator;
9
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
10
use Zend\ServiceManager\Exception\ServiceNotFoundException;
11
use Zend\ServiceManager\Factory\FactoryInterface;
12
13
class TranslatorFactory implements FactoryInterface
14
{
15
    /**
16
     * Create an object
17
     *
18
     * @param  ContainerInterface $container
19
     * @param  string $requestedName
20
     * @param  null|array $options
21
     * @return object|Translator
22
     * @throws ServiceNotFoundException if unable to resolve the service.
23
     * @throws ServiceNotCreatedException if an exception is raised when
24
     *     creating a service.
25 1
     * @throws ContainerException if any other error occurs
26
     */
27 1
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null): Translator
28 1
    {
29
        $translatorConfig = $container->get('config')['translator'];
30
        return Translator::factory($translatorConfig);
31
    }
32
}
33