LazyLoadingDriver   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadMetadataForClass() 0 3 1
A __construct() 0 8 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Metadata\Driver;
6
7
use Metadata\ClassMetadata;
8
use Psr\Container\ContainerInterface as PsrContainerInterface;
9
use Symfony\Component\DependencyInjection\ContainerInterface;
10
11
class LazyLoadingDriver implements DriverInterface
12
{
13
    /**
14
     * @var ContainerInterface|PsrContainerInterface
15
     */
16
    private $container;
17
18
    /**
19
     * @var string
20
     */
21
    private $realDriverId;
22
23
    /**
24
     * @param ContainerInterface|PsrContainerInterface $container
25
     */
26 3
    public function __construct($container, string $realDriverId)
27
    {
28 3
        if (!$container instanceof PsrContainerInterface && !$container instanceof ContainerInterface) {
0 ignored issues
show
introduced by
$container is always a sub-type of Symfony\Component\Depend...tion\ContainerInterface.
Loading history...
29 1
            throw new \InvalidArgumentException(sprintf('The container must be an instance of %s or %s (%s given).', PsrContainerInterface::class, ContainerInterface::class, \is_object($container) ? \get_class($container) : \gettype($container)));
30
        }
31
32 2
        $this->container = $container;
33 2
        $this->realDriverId = $realDriverId;
34 2
    }
35
36 2
    public function loadMetadataForClass(\ReflectionClass $class): ?ClassMetadata
37
    {
38 2
        return $this->container->get($this->realDriverId)->loadMetadataForClass($class);
39
    }
40
}
41