. */ namespace SP\Infrastructure\File; /** * Class FileCache * * @package SP\Infrastructure\File; */ class FileCache extends FileCacheBase { /** * @throws FileException */ public function load(?string $path = null): mixed { $this->checkOrInitializePath($path); /** @noinspection UnserializeExploitsInspection */ return unserialize($this->path->checkIsReadable()->readToString()); } /** * @throws FileException */ public function save(mixed $data, ?string $path = null): FileCacheInterface { $this->checkOrInitializePath($path); $this->createPath(); $this->path->checkIsWritable(); $this->path->open('wb', true); $this->path->write(serialize($data)); $this->path->close(); return $this; } }