imageOptimizerService->optimize($file); return $this->storageService->storeFileOntoDisk($optimized, $this->s3Disk->disk); } public function deleteIfReplaced( ?StorageFilePath $oldPath, ?StorageFilePath $newPath, ): void { if ($oldPath === null || $newPath === null || $oldPath->value === $newPath->value) { return; } $this->deleteIfExists($oldPath); } public function deleteIfExists(?StorageFilePath $path): void { if ($path !== null && $this->storageService->fileExistsOnDisk($path, $this->s3Disk->disk)) { $this->storageService->removeFromDisk($path, $this->s3Disk->disk); } } }