Passed
Pull Request — master (#2)
by Alex
02:54
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 13 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 Laminas\ServiceManager\Exception\ServiceNotCreatedException;
10
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
11
use Psr\Container\ContainerInterface;
12
use Psr\Log\NullLogger;
13
14
/**
15
 * @author  Alex Patterson <[email protected]>
16
 * @package Arp\LaminasDoctrine\Factory\Repository\Persistence
17
 */
18
final class CascadeDeleteServiceFactory extends AbstractFactory
19
{
20
    /**
21
     * @param ContainerInterface $container
22
     * @param string             $requestedName
23
     * @param array<mixed>|null  $options
24
     *
25
     * @return CascadeDeleteService
26
     *
27
     * @throws ServiceNotCreatedException
28
     * @throws ServiceNotFoundException
29
     */
30
    public function __invoke(
31
        ContainerInterface $container,
32
        string $requestedName,
33
        array $options = null
34
    ): CascadeDeleteService {
35
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
36
37
        $logger = $options['logger'] ?? NullLogger::class;
38
39
        return new CascadeDeleteService(
40
            $this->getService($container, $logger, $requestedName),
41
            $options['options'] ?? [],
42
            $options['collection_options'] ?? []
43
        );
44
    }
45
}
46