public function __construct(string $root, file\Driver $filesystem = null)
{
$root = \str_replace("\\", "/", $root);
if (!(\is_readable($root) && \is_dir($root))) {
throw new \DomainException("Document root requires a readable directory");
}
$this->root = \rtrim(\realpath($root), "/");
$this->filesystem = $filesystem ?: file\filesystem();
$this->multipartBoundary = \uniqid("", true);
$this->cacheWatcher = amp\repeat(function () {
$this->now = $now = time();
foreach ($this->cacheTimeouts as $path => $timeout) {
if ($now <= $timeout) {
break;
}
$fileInfo = $this->cache[$path];
unset($this->cache[$path], $this->cacheTimeouts[$path]);
$this->bufferedFileCount -= isset($fileInfo->buffer);
$this->cacheEntryCount--;
}
}, 1000, $options = ["enable" => false]);
}