VersioningConfig.php 1.3 KB

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