UniqueObjectFactory::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule\Validator\Service;
6
7
use DoctrineModule\Validator\UniqueObject;
8
use Interop\Container\ContainerInterface;
9
10
class UniqueObjectFactory extends AbstractValidatorFactory
11
{
12
    /** @var string */
13
    protected $validatorClass = UniqueObject::class;
14
15
    /**
16
     * {@inheritDoc}
17
     */
18 1
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
19
    {
20 1
        $container = $this->container($container);
21
22 1
        $useContext = isset($options['use_context']) ? (bool) $options['use_context'] : false;
23
24 1
        return new UniqueObject($this->merge($options, [
25 1
            'object_manager'    => $this->getObjectManager($container, $options),
26 1
            'use_context'       => $useContext,
27 1
            'object_repository' => $this->getRepository($container, $options),
28 1
            'fields'            => $this->getFields($options),
29
        ]));
30
    }
31
}
32