RestoreConfig.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace OSS\Model;
  3. use OSS\Core\OssException;
  4. /**
  5. * Class RestoreConfig
  6. * @package OSS\Model
  7. *
  8. */
  9. class RestoreConfig implements XmlConfig
  10. {
  11. /**
  12. * RestoreConfig constructor.
  13. * @param int $day
  14. * @param null $tier
  15. */
  16. public function __construct($day, $tier = null)
  17. {
  18. $this->day = $day;
  19. $this->tier = $tier;
  20. }
  21. /**
  22. * Parse RestoreConfig from the xml.
  23. *
  24. * @param string $strXml
  25. * @throws OssException
  26. * @return null
  27. */
  28. public function parseFromXml($strXml)
  29. {
  30. throw new OssException("Not implemented.");
  31. }
  32. /**
  33. * Serialize the object into xml string.
  34. *
  35. * @return string
  36. */
  37. public function serializeToXml()
  38. {
  39. $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RestoreRequest></RestoreRequest>');
  40. $xml->addChild('Days', strval($this->day));
  41. if (isset($this->tier)) {
  42. $xml_param = $xml->addChild('JobParameters');
  43. $xml_param->addChild('Tier', $this->tier);
  44. }
  45. return $xml->asXML();
  46. }
  47. public function __toString()
  48. {
  49. return $this->serializeToXml();
  50. }
  51. /**
  52. * @return int
  53. */
  54. public function getDay()
  55. {
  56. return $this->day;
  57. }
  58. /**
  59. * @return string
  60. */
  61. public function getTier()
  62. {
  63. return $this->tier;
  64. }
  65. private $day = 1;
  66. private $tier = 'Standard';
  67. }