RepositoryFactoryFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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