RepositoryFactoryFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 1
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