Attachment.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OC\Mail;
  26. use OCP\Mail\IAttachment;
  27. /**
  28. * Class Attachment
  29. *
  30. * @package OC\Mail
  31. * @since 13.0.0
  32. */
  33. class Attachment implements IAttachment {
  34. /** @var \Swift_Mime_Attachment */
  35. protected $swiftAttachment;
  36. public function __construct(\Swift_Mime_Attachment $attachment) {
  37. $this->swiftAttachment = $attachment;
  38. }
  39. /**
  40. * @param string $filename
  41. * @return $this
  42. * @since 13.0.0
  43. */
  44. public function setFilename(string $filename): IAttachment {
  45. $this->swiftAttachment->setFilename($filename);
  46. return $this;
  47. }
  48. /**
  49. * @param string $contentType
  50. * @return $this
  51. * @since 13.0.0
  52. */
  53. public function setContentType(string $contentType): IAttachment {
  54. $this->swiftAttachment->setContentType($contentType);
  55. return $this;
  56. }
  57. /**
  58. * @param string $body
  59. * @return $this
  60. * @since 13.0.0
  61. */
  62. public function setBody(string $body): IAttachment {
  63. $this->swiftAttachment->setBody($body);
  64. return $this;
  65. }
  66. /**
  67. * @return \Swift_Mime_Attachment
  68. */
  69. public function getSwiftAttachment(): \Swift_Mime_Attachment {
  70. return $this->swiftAttachment;
  71. }
  72. }