Passed
Pull Request — master (#5)
by Alex
09:53 queued 08:01
created

SystemClockFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasDateTime\Factory\Psr;
6
7
use Arp\DateTime\Psr\SystemClock;
8
use Arp\LaminasFactory\AbstractFactory;
9
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
10
use Psr\Container\ContainerExceptionInterface;
11
use Psr\Container\ContainerInterface;
12
13
final class SystemClockFactory extends AbstractFactory
14
{
15
    /**
16
     * @throws ContainerExceptionInterface
17
     */
18
    public function __invoke(ContainerInterface $container, string $requestedName, array $options = null): SystemClock
19
    {
20
        $options = $options ?? $this->getServiceOptions($container, $requestedName, 'laminas_date_time');
21
22
        if (empty($options['factory'])) {
23
            throw new ServiceNotCreatedException(
24
                sprintf('The required \'factory\' configuration option is missing for service \'%s\'', $requestedName),
25
            );
26
        }
27
28
        return new SystemClock(
29
            $this->getService($container, $options['factory'], $requestedName),
30
        );
31
    }
32
}
33