Completed
Push — master ( f2b8b4...a21374 )
by Tom
24s queued 11s
created

StorageFactory::__invoke()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.0123

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 9
cp 0.8889
rs 9.7333
c 0
b 0
f 0
cc 3
nc 4
nop 3
crap 3.0123
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule\Service\Authentication;
6
7
use DoctrineModule\Authentication\Storage\ObjectRepository;
8
use DoctrineModule\Options\Authentication;
9
use DoctrineModule\Service\AbstractFactory;
10
use Interop\Container\ContainerInterface;
11
use Laminas\ServiceManager\ServiceLocatorInterface;
12
use function is_string;
13
14
/**
15
 * Factory to create authentication storage object.
16
 *
17
 * @link    http://www.doctrine-project.org/
18
 */
19
class StorageFactory extends AbstractFactory
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24 3
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
25
    {
26 3
        $options = $this->getOptions($container, 'authentication');
27
28 3
        $objectManager = $options->getObjectManager();
29 3
        if (is_string($objectManager)) {
30
            $options->setObjectManager($container->get($objectManager));
31
        }
32
33 3
        $storage = $options->getStorage();
34 3
        if (is_string($storage)) {
35 3
            $options->setStorage($container->get($storage));
36
        }
37
38 3
        return new ObjectRepository($options);
0 ignored issues
show
Documentation introduced by
$options is of type object<Laminas\Stdlib\AbstractOptions>, but the function expects a array<integer,*>|object<...Options\Authentication>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     *
44
     * @return ObjectRepository
45
     */
46 2
    public function createService(ServiceLocatorInterface $container)
47
    {
48 2
        return $this($container, ObjectRepository::class);
49
    }
50
51 3
    public function getOptionsClass() : string
52
    {
53 3
        return 'DoctrineModule\Options\Authentication';
54
    }
55
}
56