EmailAddressSet.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\CalDAV\Xml\Property;
  4. use Sabre\Xml\Writer;
  5. use Sabre\Xml\XmlSerializable;
  6. /**
  7. * email-address-set property.
  8. *
  9. * This property represents the email-address-set property in the
  10. * http://calendarserver.org/ns/ namespace.
  11. *
  12. * It's a list of email addresses associated with a user.
  13. *
  14. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  15. * @author Evert Pot (http://evertpot.com/)
  16. * @license http://sabre.io/license/ Modified BSD License
  17. */
  18. class EmailAddressSet implements XmlSerializable
  19. {
  20. /**
  21. * emails.
  22. *
  23. * @var array
  24. */
  25. private $emails;
  26. /**
  27. * __construct.
  28. */
  29. public function __construct(array $emails)
  30. {
  31. $this->emails = $emails;
  32. }
  33. /**
  34. * Returns the email addresses.
  35. *
  36. * @return array
  37. */
  38. public function getValue()
  39. {
  40. return $this->emails;
  41. }
  42. /**
  43. * The xmlSerialize method is called during xml writing.
  44. *
  45. * Use the $writer argument to write its own xml serialization.
  46. *
  47. * An important note: do _not_ create a parent element. Any element
  48. * implementing XmlSerializable should only ever write what's considered
  49. * its 'inner xml'.
  50. *
  51. * The parent of the current element is responsible for writing a
  52. * containing element.
  53. *
  54. * This allows serializers to be re-used for different element names.
  55. *
  56. * If you are opening new elements, you must also close them again.
  57. */
  58. public function xmlSerialize(Writer $writer)
  59. {
  60. foreach ($this->emails as $email) {
  61. $writer->writeElement('{http://calendarserver.org/ns/}email-address', $email);
  62. }
  63. }
  64. }