Passed
Push — master ( 68959d...ba9eb0 )
by Alex
03:41 queued 01:48
created

ExecutorFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 3
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasDoctrineFixtures\Factory\Service;
6
7
use Arp\LaminasDoctrineFixtures\Service\Executor;
8
use Arp\LaminasFactory\AbstractFactory;
9
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
10
use Doctrine\ORM\EntityManagerInterface;
11
use Interop\Container\ContainerInterface;
12
13
/**
14
 * @author  Alex Patterson <[email protected]>
15
 * @package Arp\LaminasDoctrineFixtures\Factory\Service
16
 */
17
final class ExecutorFactory extends AbstractFactory
18
{
19
    /**
20
     * @param ContainerInterface $container
21
     * @param string             $requestedName
22
     * @param array|null         $options
23
     *
24
     * @return object|void
25
     */
26
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
27
    {
28
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
29
30
        $entityManager = $options['entity_manager'] ?? EntityManagerInterface::class;
31
        $purger = $options['purger'] ?? ORMPurger::class;
32
33
        return new Executor(
34
            $this->getService($container, $entityManager, $requestedName),
35
            $this->getService($container, $purger, $requestedName)
36
        );
37
    }
38
}
39