for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Ivory Serializer package.
*
* (c) Eric GELOEN <[email protected]>
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*/
namespace Ivory\Serializer\Mapping\Factory;
use Psr\Cache\CacheItemPoolInterface;
/**
* @author GeLo <[email protected]>
class CacheClassMetadataFactory extends AbstractClassMetadataFactory
{
* @var ClassMetadataFactoryInterface
private $factory;
* @var CacheItemPoolInterface
private $pool;
* @param ClassMetadataFactoryInterface $factory
* @param CacheItemPoolInterface $pool
public function __construct(ClassMetadataFactoryInterface $factory, CacheItemPoolInterface $pool)
$this->factory = $factory;
$this->pool = $pool;
}
* {@inheritdoc}
protected function fetchClassMetadata($class)
$item = $this->pool->getItem(strtr($class, '\\', '_'));
if ($item->isHit()) {
return $item->get();
$classMetadata = $this->factory->getClassMetadata($class);
$this->pool->save($item->set($classMetadata));
return $classMetadata;