Dashboard sipadu mbip
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

AbstractPart.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Mime\Part;
  11. use Symfony\Component\Mime\Header\Headers;
  12. /**
  13. * @author Fabien Potencier <fabien@symfony.com>
  14. *
  15. * @experimental in 4.3
  16. */
  17. abstract class AbstractPart
  18. {
  19. private $headers;
  20. public function __construct()
  21. {
  22. $this->headers = new Headers();
  23. }
  24. public function getHeaders(): Headers
  25. {
  26. return $this->headers;
  27. }
  28. public function getPreparedHeaders(): Headers
  29. {
  30. $headers = clone $this->headers;
  31. $headers->setHeaderBody('Parameterized', 'Content-Type', $this->getMediaType().'/'.$this->getMediaSubtype());
  32. return $headers;
  33. }
  34. public function toString(): string
  35. {
  36. return $this->getPreparedHeaders()->toString()."\r\n".$this->bodyToString();
  37. }
  38. public function toIterable(): iterable
  39. {
  40. yield $this->getPreparedHeaders()->toString();
  41. yield "\r\n";
  42. yield from $this->bodyToIterable();
  43. }
  44. abstract public function bodyToString(): string;
  45. abstract public function bodyToIterable(): iterable;
  46. abstract public function getMediaType(): string;
  47. abstract public function getMediaSubtype(): string;
  48. }