DocXEncoder.php 902 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Service\Export\Encoder;
  4. use Phpdocx\Create\CreateDocx;
  5. use App\Enum\Export\ExportFormatEnum;
  6. /**
  7. * Encode HTML to docx format
  8. */
  9. class DocXEncoder implements EncoderInterface
  10. {
  11. public function support(string $format): bool
  12. {
  13. return $format === ExportFormatEnum::DOCX()->getValue();
  14. }
  15. // TODO: resolve Phpstan errors
  16. /**
  17. * Encode the given HTML content into docX, and
  18. * return the encoded content
  19. *
  20. * @param string $html
  21. * @param array<mixed> $options
  22. * @return string
  23. */
  24. public function encode(string $html, array $options = []): string
  25. {
  26. // $docx = new CreateDocx();
  27. // $docx->embedHTML($html);
  28. // $tempFile = tempnam(sys_get_temp_dir(), 'docx');
  29. // $docx->createDocx($tempFile);
  30. // $content = file_get_contents($tempFile);
  31. // unlink($tempFile);
  32. // return $content;
  33. return "";
  34. }
  35. }