ListBucketsResult.php 765 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace OSS\Result;
  3. use OSS\Model\BucketInfo;
  4. use OSS\Model\BucketListInfo;
  5. /**
  6. * Class ListBucketsResult
  7. *
  8. * @package OSS\Result
  9. */
  10. class ListBucketsResult extends Result
  11. {
  12. /**
  13. * @return BucketListInfo
  14. */
  15. protected function parseDataFromResponse()
  16. {
  17. $bucketList = array();
  18. $content = $this->rawResponse->body;
  19. $xml = new \SimpleXMLElement($content);
  20. if (isset($xml->Buckets) && isset($xml->Buckets->Bucket)) {
  21. foreach ($xml->Buckets->Bucket as $bucket) {
  22. $bucketInfo = new BucketInfo();
  23. $bucketInfo->parseFromXmlNode($bucket);
  24. $bucketList[] = $bucketInfo;
  25. }
  26. }
  27. return new BucketListInfo($bucketList);
  28. }
  29. }