class CachedMappedAssetFactory implements MappedAssetFactoryInterface
{ public function __construct( private readonly MappedAssetFactoryInterface
$innerFactory,
private readonly string
$cacheDir,
private readonly bool
$debug,
) { } public function createMappedAsset(string
$logicalPath, string
$sourcePath): ?MappedAsset
{ $cachePath =
$this->
getCacheFilePath($logicalPath,
$sourcePath);
$configCache =
new ConfigCache($cachePath,
$this->debug
);
if ($configCache->
isFresh()) { return unserialize(file_get_contents($cachePath));
} $mappedAsset =
$this->innerFactory->
createMappedAsset($logicalPath,
$sourcePath);
if (!
$mappedAsset) { return null;
}