vendor/jms/metadata/src/Driver/LazyLoadingDriver.php line 38

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Metadata\Driver;
  4. use Metadata\ClassMetadata;
  5. use Psr\Container\ContainerInterface as PsrContainerInterface;
  6. use Symfony\Component\DependencyInjection\ContainerInterface;
  7. class LazyLoadingDriver implements DriverInterface
  8. {
  9.     /**
  10.      * @var ContainerInterface|PsrContainerInterface
  11.      */
  12.     private $container;
  13.     /**
  14.      * @var string
  15.      */
  16.     private $realDriverId;
  17.     /**
  18.      * @param ContainerInterface|PsrContainerInterface $container
  19.      */
  20.     public function __construct($containerstring $realDriverId)
  21.     {
  22.         if (!$container instanceof PsrContainerInterface && !$container instanceof ContainerInterface) {
  23.             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)));
  24.         }
  25.         $this->container $container;
  26.         $this->realDriverId $realDriverId;
  27.     }
  28.     public function loadMetadataForClass(\ReflectionClass $class): ?ClassMetadata
  29.     {
  30.         return $this->container->get($this->realDriverId)->loadMetadataForClass($class);
  31.     }
  32. }