Passed
Pull Request — master (#2)
by Alex
03:06
created

CascadeDeleteServiceFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasDoctrine\Factory\Repository\Persistence;
6
7
use Arp\DoctrineEntityRepository\Persistence\CascadeDeleteService;
8
use Arp\LaminasFactory\AbstractFactory;
9
use Arp\LaminasMonolog\Factory\FactoryLoggerProviderTrait;
10
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
11
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
12
use Laminas\ServiceManager\ServiceLocatorInterface;
13
use Psr\Container\ContainerInterface;
14
15
/**
16
 * @author  Alex Patterson <[email protected]>
17
 * @package Arp\LaminasDoctrine\Factory\Repository\Persistence
18
 */
19
final class CascadeDeleteServiceFactory extends AbstractFactory
20
{
21
    use FactoryLoggerProviderTrait;
22
23
    /**
24
     * @param ContainerInterface&ServiceLocatorInterface $container
25
     * @param string                                     $requestedName
26
     * @param array<mixed>|null                          $options
27
     *
28
     * @return CascadeDeleteService
29
     *
30
     * @throws ServiceNotCreatedException
31
     * @throws ServiceNotFoundException
32
     */
33
    public function __invoke(
34
        ContainerInterface $container,
35
        string $requestedName,
36
        array $options = null
37
    ): CascadeDeleteService {
38
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
39
40
        return new CascadeDeleteService(
41
            $this->getLogger($container, $options['logger'] ?? null, $requestedName),
42
            $options['options'] ?? [],
43
            $options['collection_options'] ?? []
44
        );
45
    }
46
}
47