3 declare(strict_types=1);
5 namespace CuyZ\Valinor\Mapper\Object\Factory;
7 use CuyZ\Valinor\Definition\ClassDefinition;
8 use CuyZ\Valinor\Mapper\Object\ObjectBuilder;
9 use Psr\SimpleCache\CacheInterface;
12 final class CacheObjectBuilderFactory implements ObjectBuilderFactory
14 public function __construct(
15 private ObjectBuilderFactory $delegate,
16 /** @var CacheInterface<list<ObjectBuilder>> */
17 private CacheInterface $cache
21 public function for(ClassDefinition $class): array
23 $signature = $class->type()->toString();
25 $entry = $this->cache->get($signature);
31 $builders = $this->delegate->for($class);
33 $this->cache->set($signature, $builders);