Passed
Pull Request — master (#2)
by Alex
24:05 queued 15:48
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
 * @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