PathHeader.php 1.2 KB

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\Header;
  11. use Symfony\Component\Mime\Address;
  12. use Symfony\Component\Mime\Exception\RfcComplianceException;
  13. /**
  14. * A Path Header, such a Return-Path (one address).
  15. *
  16. * @author Chris Corbyn
  17. */
  18. final class PathHeader extends AbstractHeader
  19. {
  20. private $address;
  21. public function __construct(string $name, Address $address)
  22. {
  23. parent::__construct($name);
  24. $this->setAddress($address);
  25. }
  26. /**
  27. * @param Address $body
  28. *
  29. * @throws RfcComplianceException
  30. */
  31. public function setBody($body)
  32. {
  33. $this->setAddress($body);
  34. }
  35. public function getBody(): Address
  36. {
  37. return $this->getAddress();
  38. }
  39. public function setAddress(Address $address)
  40. {
  41. $this->address = $address;
  42. }
  43. public function getAddress(): Address
  44. {
  45. return $this->address;
  46. }
  47. public function getBodyAsString(): string
  48. {
  49. return '<'.$this->address->toString().'>';
  50. }
  51. }