Ei kuvausta

MessageAttributes.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace AliyunMNS\Model;
  3. use AliyunMNS\Constants;
  4. /**
  5. * Please refer to
  6. * https://docs.aliyun.com/?spm=#/pub/mns/api_reference/intro&intro
  7. * for more details
  8. */
  9. class MessageAttributes
  10. {
  11. // if both SmsAttributes and BatchSmsAttributes are set, only one will take effect
  12. private $attributes;
  13. public function __construct(
  14. $attributes = NULL)
  15. {
  16. $this->attributes = $attributes;
  17. }
  18. public function setAttributes($attributes)
  19. {
  20. $this->attributes = $attributes;
  21. }
  22. public function getAttributes()
  23. {
  24. return $this->attributes;
  25. }
  26. public function writeXML(\XMLWriter $xmlWriter)
  27. {
  28. $xmlWriter->startELement(Constants::MESSAGE_ATTRIBUTES);
  29. if ($this->attributes != NULL)
  30. {
  31. if (is_array($this->attributes))
  32. {
  33. foreach ($this->attributes as $subAttributes)
  34. {
  35. $subAttributes->writeXML($xmlWriter);
  36. }
  37. }
  38. else
  39. {
  40. $this->attributes->writeXML($xmlWriter);
  41. }
  42. }
  43. $xmlWriter->endElement();
  44. }
  45. }
  46. ?>