RequestPaymentConfig.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace OSS\Model;
  3. use OSS\Core\OssException;
  4. /**
  5. * Class RequestPaymentConfig
  6. * @package OSS\Model
  7. *
  8. * @link https://help.aliyun.com/document_detail/117914.htm
  9. */
  10. class RequestPaymentConfig implements XmlConfig
  11. {
  12. /**
  13. * RequestPaymentConfig constructor.
  14. * @param null $payer
  15. */
  16. public function __construct($payer = null)
  17. {
  18. $this->payer = $payer;
  19. }
  20. /**
  21. * Parse ServerSideEncryptionConfig from the xml.
  22. *
  23. * @param string $strXml
  24. * @throws OssException
  25. * @return null
  26. */
  27. public function parseFromXml($strXml)
  28. {
  29. $xml = simplexml_load_string($strXml);
  30. if (isset($xml->Payer)) {
  31. $this->payer = strval($xml->Payer);
  32. }
  33. }
  34. /**
  35. * Serialize the object into xml string.
  36. *
  37. * @return string
  38. */
  39. public function serializeToXml()
  40. {
  41. $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RequestPaymentConfiguration></RequestPaymentConfiguration>');
  42. if (isset($this->payer)) {
  43. $xml->addChild('Payer', $this->payer);
  44. }
  45. return $xml->asXML();
  46. }
  47. public function __toString()
  48. {
  49. return $this->serializeToXml();
  50. }
  51. /**
  52. * @return string
  53. */
  54. public function getPayer()
  55. {
  56. return $this->payer;
  57. }
  58. private $payer = "";
  59. }