value; } // TODO: resolve Phpstan errors /** * Encode the given HTML content into docX, and * return the encoded content. * * @param array $options * @throws Throwable */ public function encode(string $html, array $options = []): string { $tempFilename = $this->fileUtils->getTempFilename('docx'); // @see https://www.phpdocx.com/documentation/introduction/html-to-word-PHP# $this->phpDocx->embedHTML($html); try { $this->phpDocx->createDocx($tempFilename); return file_get_contents($tempFilename); } catch (\Throwable $e) { if (is_file($tempFilename)) { unlink($tempFilename); } throw $e; } } }