GetBucketInfoResult.php 859 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace OSS\Result;
  3. use OSS\Core\OssException;
  4. use OSS\Model\BucketInfo;
  5. /**
  6. * Class GetBucketResult interface returns the result class, encapsulated
  7. * The returned xml data is parsed
  8. *
  9. * @package OSS\Result
  10. */
  11. class GetBucketInfoResult extends Result
  12. {
  13. /**
  14. * Parse data from response
  15. *
  16. * @return string
  17. * @throws OssException
  18. */
  19. protected function parseDataFromResponse()
  20. {
  21. $content = $this->rawResponse->body;
  22. if (empty($content)) {
  23. throw new OssException("body is null");
  24. }
  25. $xml = simplexml_load_string($content);
  26. if (isset($xml->Bucket)) {
  27. $info = new BucketInfo();
  28. $info->parseFromXmlNode($xml->Bucket);
  29. return $info;
  30. } else {
  31. throw new OssException("xml format exception");
  32. }
  33. }
  34. }