ListBucketsResult.php 828 B

123456789101112131415161718192021222324252627282930313233
  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(strval($bucket->Location),
  23. strval($bucket->Name),
  24. strval($bucket->CreationDate));
  25. $bucketList[] = $bucketInfo;
  26. }
  27. }
  28. return new BucketListInfo($bucketList);
  29. }
  30. }