ProxyDriverFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fabiang\DoctrineDynamic\Service;
6
7
use Doctrine\ORM\EntityManager;
8
use Fabiang\DoctrineDynamic\Configuration;
9
use Fabiang\DoctrineDynamic\ProxyDriver;
10
use Fabiang\DoctrineDynamic\ProxyDriverFactory as BaseProxyDriverFactory;
11
use Laminas\ServiceManager\Factory\FactoryInterface;
12
use Psr\Container\ContainerInterface;
13
14
final class ProxyDriverFactory extends BaseProxyDriverFactory implements
15
    FactoryInterface
16
{
17
    /**
18
     * @param string $requestedName
19
     * @return ProxyDriver[]
20
     */
21 1
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): array
22
    {
23 1
        $entityManager = $container->get(EntityManager::class);
24 1
        $configuration = $container->get(Configuration::class);
25 1
        return $this->factory($entityManager, $configuration);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->factory($e...anager, $configuration) returns the type array which is incompatible with the return type mandated by Laminas\ServiceManager\F...ryInterface::__invoke() of object.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
26
    }
27
}
28