Passed
Pull Request — master (#2)
by Alex
08:14
created

CascadeDeleteServiceFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 3
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
 * @deprecated
17
 *
18
 * @author  Alex Patterson <[email protected]>
19
 * @package Arp\LaminasDoctrine\Factory\Repository\Persistence
20
 */
21
final class CascadeDeleteServiceFactory extends AbstractFactory
22
{
23
    use FactoryLoggerProviderTrait;
24
25
    /**
26
     * @param ContainerInterface&ServiceLocatorInterface $container
27
     * @param string                                     $requestedName
28
     * @param array<mixed>|null                          $options
29
     *
30
     * @return CascadeDeleteService
31
     *
32
     * @throws ServiceNotCreatedException
33
     * @throws ServiceNotFoundException
34
     */
35
    public function __invoke(
36
        ContainerInterface $container,
37
        string $requestedName,
38
        array $options = null
39
    ): CascadeDeleteService {
40
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
41
42
        return new CascadeDeleteService(
43
            $this->getLogger($container, $options['logger'] ?? null, $requestedName),
44
            $options['options'] ?? [],
45
            $options['collection_options'] ?? []
46
        );
47
    }
48
}
49