/**
  * Creates ListBlobsResult object from parsed XML response.
  *
  * @param array $parsed XML response parsed into array.
  * 
  * @return ListBlobsResult
  */
 public static function create($parsed)
 {
     $result = new ListBlobsResult();
     $serviceEndpoint = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_ATTRIBUTES, Resources::XTAG_SERVICE_ENDPOINT);
     $containerName = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_ATTRIBUTES, Resources::XTAG_CONTAINER_NAME);
     $result->_containerName = $containerName;
     $result->_prefix = Utilities::tryGetValue($parsed, Resources::QP_PREFIX);
     $result->_marker = Utilities::tryGetValue($parsed, Resources::QP_MARKER);
     $result->_nextMarker = Utilities::tryGetValue($parsed, Resources::QP_NEXT_MARKER);
     $result->_maxResults = intval(Utilities::tryGetValue($parsed, Resources::QP_MAX_RESULTS, 0));
     $result->_delimiter = Utilities::tryGetValue($parsed, Resources::QP_DELIMITER);
     $result->_blobs = array();
     $result->_blobPrefixes = array();
     $rawBlobs = array();
     $rawBlobPrefixes = array();
     if (is_array($parsed['Blobs']) && array_key_exists('Blob', $parsed['Blobs'])) {
         $rawBlobs = Utilities::getArray($parsed['Blobs']['Blob']);
     }
     foreach ($rawBlobs as $value) {
         $blob = new Blob();
         $blob->setName($value['Name']);
         $blob->setUrl($serviceEndpoint . $containerName . '/' . $value['Name']);
         $blob->setSnapshot(Utilities::tryGetValue($value, 'Snapshot'));
         $blob->setProperties(BlobProperties::create(Utilities::tryGetValue($value, 'Properties')));
         $blob->setMetadata(Utilities::tryGetValue($value, Resources::QP_METADATA, array()));
         $result->_blobs[] = $blob;
     }
     if (is_array($parsed['Blobs']) && array_key_exists('BlobPrefix', $parsed['Blobs'])) {
         $rawBlobPrefixes = Utilities::getArray($parsed['Blobs']['BlobPrefix']);
     }
     foreach ($rawBlobPrefixes as $value) {
         $blobPrefix = new BlobPrefix();
         $blobPrefix->setName($value['Name']);
         $result->_blobPrefixes[] = $blobPrefix;
     }
     return $result;
 }
Example #2
0
 /**
  * @covers MicrosoftAzure\Storage\Blob\Models\Blob::getProperties
  */
 public function testGetProperties()
 {
     // Setup
     $blob = new Blob();
     $expected = new BlobProperties();
     $blob->setProperties($expected);
     // Test
     $actual = $blob->getProperties();
     // Assert
     $this->assertEquals($expected, $actual);
 }