Passed
Push — master ( 79bf3c...52a24b )
by Alex
01:04 queued 13s
created

ConnectionConfigsFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasDoctrine\Factory\Config;
6
7
use Arp\LaminasDoctrine\Config\ConnectionConfigs;
8
use Arp\LaminasFactory\AbstractFactory;
9
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
10
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
11
use Psr\Container\ContainerExceptionInterface;
12
use Psr\Container\ContainerInterface;
13
14
/**
15
 * @author  Alex Patterson <[email protected]>
16
 * @package Arp\LaminasDoctrine\Factory\Config
17
 */
18
final class ConnectionConfigsFactory extends AbstractFactory
19
{
20
    /**
21
     * @param ContainerInterface $container
22
     * @param string             $requestedName
23
     * @param array<mixed>|null  $options
24
     *
25
     * @return ConnectionConfigs
26
     *
27
     * @throws ServiceNotCreatedException
28
     * @throws ServiceNotFoundException
29
     * @throws ContainerExceptionInterface
30
     */
31
    public function __invoke(
32
        ContainerInterface $container,
33
        string $requestedName,
34
        array $options = null
35
    ): ConnectionConfigs {
36
        $configs = $this->getApplicationOptions($container, 'doctrine');
37
38
        return new ConnectionConfigs($configs['connection'] ?? []);
39
    }
40
}
41