private function putOrMergeEntityAsyncImpl(
        $table,
        Entity $entity,
        $verb,
        $useETag,
        TableServiceOptions $options = null
    ) {
        $context = $this->constructPutOrMergeEntityContext(
            $table,
            $entity,
            $verb,
            $useETag,
            $options
        );

        return $this->sendContextAsync($context)->then(function ($response) {
            return UpdateEntityResult::create(
                HttpFormatter::formatHeaders($response->getHeaders())
            );
        }, null);
    }

private function putOrMergeEntityAsyncImpl ( $ table , Entity $ entity , $ verb , $ useETag , TableServiceOptions $ options = null ) { $ context = $ this -> constructPutOrMergeEntityContext ( $ table , $ entity , $ verb , $ useETag , $ options ) ; return $ this -> sendContextAsync ( $ context ) -> then ( function ( $ response ) { return UpdateEntityResult :: create ( HttpFormatter :: formatHeaders ( $ response -> getHeaders ( ) ) ) ; } , null ) ; }

Creates a promie that does the actual work for update and merge entity
APIs.

@param string              $table   The table name.
@param Entity              $entity  The entity instance to use.
@param string              $verb    The HTTP method.
@param boolean             $useETag The flag to include etag or not.
@param TableServiceOptions $options The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

Creates a promie that does the actual work for update and merge entity APIs .


private function addOptionalQuery(array $queryParam, Query $query)
    {
        if (!is_null($query)) {
            $selectedFields = $query->getSelectFields();
            if (!empty($selectedFields)) {
                $final = $this->encodeODataUriValues($selectedFields);

                $this->addOptionalQueryParam(
                    $queryParam,
                    Resources::QP_SELECT,
                    implode(',', $final)
                );
            }

            if (!is_null($query->getTop())) {
                $final = strval($this->encodeODataUriValue($query->getTop()));

                $this->addOptionalQueryParam(
                    $queryParam,
                    Resources::QP_TOP,
                    $final
                );
            }

            if (!is_null($query->getFilter())) {
                $final = $this->buildFilterExpression($query->getFilter());
                $this->addOptionalQueryParam(
                    $queryParam,
                    Resources::QP_FILTER,
                    $final
                );
            }
        }

        return $queryParam;
    }

private function addOptionalQuery ( array $ queryParam , Query $ query ) { if ( ! is_null ( $ query ) ) { $ selectedFields = $ query -> getSelectFields ( ) ; if ( ! empty ( $ selectedFields ) ) { $ final = $ this -> encodeODataUriValues ( $ selectedFields ) ; $ this -> addOptionalQueryParam ( $ queryParam , Resources :: QP_SELECT , implode ( ',' , $ final ) ) ; } if ( ! is_null ( $ query -> getTop ( ) ) ) { $ final = strval ( $ this -> encodeODataUriValue ( $ query -> getTop ( ) ) ) ; $ this -> addOptionalQueryParam ( $ queryParam , Resources :: QP_TOP , $ final ) ; } if ( ! is_null ( $ query -> getFilter ( ) ) ) { $ final = $ this -> buildFilterExpression ( $ query -> getFilter ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParam , Resources :: QP_FILTER , $ final ) ; } } return $ queryParam ; }

Adds query object to the query parameter array

@param array $queryParam The URI query parameters
@param Query $query      The query object

@return array


private function encodeODataUriValues(array $values)
    {
        $list = array();

        foreach ($values as $value) {
            $list[] = $this->encodeODataUriValue($value);
        }

        return $list;
    }

private function encodeODataUriValues ( array $ values ) { $ list = array ( ) ; foreach ( $ values as $ value ) { $ list [ ] = $ this -> encodeODataUriValue ( $ value ) ; } return $ list ; }

Encodes OData URI values

@param array $values The OData URL values

@return array


public function queryTablesAsync($options = null)
    {
        $method      = Resources::HTTP_GET;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = 'Tables';

        if (is_null($options)) {
            $options = new QueryTablesOptions();
        } elseif (is_string($options)) {
            $prefix  = $options;
            $options = new QueryTablesOptions();
            $options->setPrefix($prefix);
        } elseif ($options instanceof Filter) {
            $filter  = $options;
            $options = new QueryTablesOptions();
            $options->setFilter($filter);
        }

        $query   = $options->getQuery();
        $next    = $options->getNextTableName();
        $prefix  = $options->getPrefix();

        if (!empty($prefix)) {
            // Append Max char to end '{' is 1 + 'z' in AsciiTable ==> upperBound
            // is prefix + '{'
            $prefixFilter = Filter::applyAnd(
                Filter::applyGe(
                    Filter::applyPropertyName('TableName'),
                    Filter::applyConstant($prefix, EdmType::STRING)
                ),
                Filter::applyLe(
                    Filter::applyPropertyName('TableName'),
                    Filter::applyConstant($prefix . '{', EdmType::STRING)
                )
            );

            if (is_null($query)) {
                $query = new Query();
            }

            if (is_null($query->getFilter())) {
                // use the prefix filter if the query filter is null
                $query->setFilter($prefixFilter);
            } else {
                // combine and use the prefix filter if the query filter exists
                $combinedFilter = Filter::applyAnd(
                    $query->getFilter(),
                    $prefixFilter
                );
                $query->setFilter($combinedFilter);
            }
        }

        $queryParams = $this->addOptionalQuery($queryParams, $query);

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_NEXT_TABLE_NAME,
            $next
        );
        $this->addOptionalHeader(
            $headers,
            Resources::ACCEPT_HEADER,
            $options->getAccept()
        );

        // One can specify the NextTableName option to get table entities starting
        // from the specified name. However, there appears to be an issue in the
        // Azure Table service where this does not engage on the server unless
        // $filter appears in the URL. The current behavior is to just ignore the
        // NextTableName options, which is not expected or easily detectable.
        if (array_key_exists(Resources::QP_NEXT_TABLE_NAME, $queryParams)
            && !array_key_exists(Resources::QP_FILTER, $queryParams)
        ) {
            $queryParams[Resources::QP_FILTER] = Resources::EMPTY_STRING;
        }

        $odataSerializer = $this->odataSerializer;

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) use ($odataSerializer) {
            $tables = $odataSerializer->parseTableEntries($response->getBody());
            return QueryTablesResult::create(
                HttpFormatter::formatHeaders($response->getHeaders()),
                $tables
            );
        }, null);
    }

Creates promise to query the tables in the given storage account.

@param QueryTablesOptions|string|Filter $options Could be optional
parameters, table prefix
or filter to apply.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/query-tables

Creates promise to query the tables in the given storage account .


public function createTable($table, TableServiceCreateOptions $options = null)
    {
        return $this->createTableAsync($table, $options)->wait();
    }

public function createTable ( $ table , TableServiceCreateOptions $ options = null ) { return $ this -> createTableAsync ( $ table , $ options ) -> wait ( ) ; }

Creates new table in the storage account

@param string                    $table   The name of the table.
@param TableServiceCreateOptions $options The optional parameters.

@return \Psr\Http\Message\ResponseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/create-table


public function createTableAsync(
        $table,
        TableServiceCreateOptions $options = null
    ) {
        Validate::canCastAsString($table, 'table');
        Validate::notNullOrEmpty($table, 'table');

        $method      = Resources::HTTP_POST;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = 'Tables';
        $body        = $this->odataSerializer->getTable($table);

        if (is_null($options)) {
            $options = new TableServiceCreateOptions();
        }

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_TYPE,
            Resources::JSON_CONTENT_TYPE
        );
        $this->addOptionalHeader(
            $headers,
            Resources::ACCEPT_HEADER,
            $options->getAccept()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::PREFER,
            $options->getDoesReturnContent() ? Resources::RETURN_CONTENT : null
        );
        $options->setLocationMode(LocationMode::PRIMARY_ONLY);

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_CREATED,
            $body,
            $options
        );
    }

public function createTableAsync ( $ table , TableServiceCreateOptions $ options = null ) { Validate :: canCastAsString ( $ table , 'table' ) ; Validate :: notNullOrEmpty ( $ table , 'table' ) ; $ method = Resources :: HTTP_POST ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = 'Tables' ; $ body = $ this -> odataSerializer -> getTable ( $ table ) ; if ( is_null ( $ options ) ) { $ options = new TableServiceCreateOptions ( ) ; } $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_TYPE , Resources :: JSON_CONTENT_TYPE ) ; $ this -> addOptionalHeader ( $ headers , Resources :: ACCEPT_HEADER , $ options -> getAccept ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: PREFER , $ options -> getDoesReturnContent ( ) ? Resources :: RETURN_CONTENT : null ) ; $ options -> setLocationMode ( LocationMode :: PRIMARY_ONLY ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_CREATED , $ body , $ options ) ; }

Creates promise to create new table in the storage account

@param string                    $table   The name of the table.
@param TableServiceCreateOptions $options The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/create-table


public function getTable($table, GetTableOptions $options = null)
    {
        return $this->getTableAsync($table, $options)->wait();
    }

public function getTable ( $ table , GetTableOptions $ options = null ) { return $ this -> getTableAsync ( $ table , $ options ) -> wait ( ) ; }

Gets the table.

@param string          $table   The name of the table.
@param GetTableOptions $options The optional parameters.

@return GetTableResult


public function getTableAsync(
        $table,
        GetTableOptions $options = null
    ) {
        Validate::canCastAsString($table, 'table');
        Validate::notNullOrEmpty($table, 'table');

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = "Tables('$table')";

        if (is_null($options)) {
            $options = new GetTableOptions();
        }

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_TYPE,
            Resources::JSON_CONTENT_TYPE
        );
        $this->addOptionalHeader(
            $headers,
            Resources::ACCEPT_HEADER,
            $options->getAccept()
        );

        $odataSerializer = $this->odataSerializer;

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) use ($odataSerializer) {
            return GetTableResult::create($response->getBody(), $odataSerializer);
        }, null);
    }

public function getTableAsync ( $ table , GetTableOptions $ options = null ) { Validate :: canCastAsString ( $ table , 'table' ) ; Validate :: notNullOrEmpty ( $ table , 'table' ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = "Tables('$table')" ; if ( is_null ( $ options ) ) { $ options = new GetTableOptions ( ) ; } $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_TYPE , Resources :: JSON_CONTENT_TYPE ) ; $ this -> addOptionalHeader ( $ headers , Resources :: ACCEPT_HEADER , $ options -> getAccept ( ) ) ; $ odataSerializer = $ this -> odataSerializer ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) use ( $ odataSerializer ) { return GetTableResult :: create ( $ response -> getBody ( ) , $ odataSerializer ) ; } , null ) ; }

Creates the promise to get the table.

@param string          $table   The name of the table.
@param GetTableOptions $options The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface


public function deleteTable($table, TableServiceOptions $options = null)
    {
        $this->deleteTableAsync($table, $options)->wait();
    }

public function deleteTable ( $ table , TableServiceOptions $ options = null ) { $ this -> deleteTableAsync ( $ table , $ options ) -> wait ( ) ; }

Deletes the specified table and any data it contains.

@param string              $table   The name of the table.
@param TableServiceOptions $options optional parameters

@return void

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd179387.aspx

Deletes the specified table and any data it contains .


public function deleteTableAsync(
        $table,
        TableServiceOptions$options = null
    ) {
        Validate::canCastAsString($table, 'table');
        Validate::notNullOrEmpty($table, 'table');

        $method      = Resources::HTTP_DELETE;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = "Tables('$table')";

        if (is_null($options)) {
            $options = new TableServiceOptions();
        }

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_NO_CONTENT,
            Resources::EMPTY_STRING,
            $options
        );
    }

public function deleteTableAsync ( $ table , TableServiceOptions $ options = null ) { Validate :: canCastAsString ( $ table , 'table' ) ; Validate :: notNullOrEmpty ( $ table , 'table' ) ; $ method = Resources :: HTTP_DELETE ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = "Tables('$table')" ; if ( is_null ( $ options ) ) { $ options = new TableServiceOptions ( ) ; } return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_NO_CONTENT , Resources :: EMPTY_STRING , $ options ) ; }

Creates promise to delete the specified table and any data it contains.

@param string              $table   The name of the table.
@param TableServiceOptions $options optional parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd179387.aspx

Creates promise to delete the specified table and any data it contains .


public function queryEntitiesAsync($table, $options = null)
    {
        Validate::canCastAsString($table, 'table');
        Validate::notNullOrEmpty($table, 'table');

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $table;

        if (is_null($options)) {
            $options = new QueryEntitiesOptions();
        } elseif (is_string($options)) {
            $queryString = $options;
            $options     = new QueryEntitiesOptions();
            $options->setFilter(Filter::applyQueryString($queryString));
        } elseif ($options instanceof Filter) {
            $filter  = $options;
            $options = new QueryEntitiesOptions();
            $options->setFilter($filter);
        }

        $queryParams = $this->addOptionalQuery($queryParams, $options->getQuery());

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_NEXT_PK,
            $options->getNextPartitionKey()
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_NEXT_RK,
            $options->getNextRowKey()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_TYPE,
            Resources::JSON_CONTENT_TYPE
        );

        $this->addOptionalHeader(
            $headers,
            Resources::ACCEPT_HEADER,
            $options->getAccept()
        );

        if (!is_null($options->getQuery())) {
            $dsHeader   = Resources::DATA_SERVICE_VERSION;
            $maxdsValue = Resources::MAX_DATA_SERVICE_VERSION_VALUE;
            $fields     = $options->getQuery()->getSelectFields();
            $hasSelect  = !empty($fields);
            if ($hasSelect) {
                $this->addOptionalHeader($headers, $dsHeader, $maxdsValue);
            }
        }

        $odataSerializer = $this->odataSerializer;

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) use ($odataSerializer) {
            $entities = $odataSerializer->parseEntities($response->getBody());

            return QueryEntitiesResult::create(
                HttpFormatter::formatHeaders($response->getHeaders()),
                $entities
            );
        }, null);
    }

public function queryEntitiesAsync ( $ table , $ options = null ) { Validate :: canCastAsString ( $ table , 'table' ) ; Validate :: notNullOrEmpty ( $ table , 'table' ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ table ; if ( is_null ( $ options ) ) { $ options = new QueryEntitiesOptions ( ) ; } elseif ( is_string ( $ options ) ) { $ queryString = $ options ; $ options = new QueryEntitiesOptions ( ) ; $ options -> setFilter ( Filter :: applyQueryString ( $ queryString ) ) ; } elseif ( $ options instanceof Filter ) { $ filter = $ options ; $ options = new QueryEntitiesOptions ( ) ; $ options -> setFilter ( $ filter ) ; } $ queryParams = $ this -> addOptionalQuery ( $ queryParams , $ options -> getQuery ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_NEXT_PK , $ options -> getNextPartitionKey ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_NEXT_RK , $ options -> getNextRowKey ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_TYPE , Resources :: JSON_CONTENT_TYPE ) ; $ this -> addOptionalHeader ( $ headers , Resources :: ACCEPT_HEADER , $ options -> getAccept ( ) ) ; if ( ! is_null ( $ options -> getQuery ( ) ) ) { $ dsHeader = Resources :: DATA_SERVICE_VERSION ; $ maxdsValue = Resources :: MAX_DATA_SERVICE_VERSION_VALUE ; $ fields = $ options -> getQuery ( ) -> getSelectFields ( ) ; $ hasSelect = ! empty ( $ fields ) ; if ( $ hasSelect ) { $ this -> addOptionalHeader ( $ headers , $ dsHeader , $ maxdsValue ) ; } } $ odataSerializer = $ this -> odataSerializer ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) use ( $ odataSerializer ) { $ entities = $ odataSerializer -> parseEntities ( $ response -> getBody ( ) ) ; return QueryEntitiesResult :: create ( HttpFormatter :: formatHeaders ( $ response -> getHeaders ( ) ) , $ entities ) ; } , null ) ; }

Quries entities for the given table name

@param string                             $table   The name of the table.
@param QueryEntitiesOptions|string|Filter $options Coule be optional
parameters, query
string or filter to
apply.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/query-entities


public function insertOrMergeEntity(
        $table,
        Entity $entity,
        TableServiceOptions $options = null
    ) {
        return $this->insertOrMergeEntityAsync($table, $entity, $options)->wait();
    }

public function insertOrMergeEntity ( $ table , Entity $ entity , TableServiceOptions $ options = null ) { return $ this -> insertOrMergeEntityAsync ( $ table , $ entity , $ options ) -> wait ( ) ; }

Updates an existing entity or inserts a new entity if it does not exist
in the table.

@param string              $table   name of the table
@param Entity              $entity  table entity
@param TableServiceOptions $options optional parameters

@return UpdateEntityResult

@see http://msdn.microsoft.com/en-us/library/windowsazure/hh452241.aspx

Updates an existing entity or inserts a new entity if it does not exist in the table .


public function insertOrMergeEntityAsync(
        $table,
        Entity $entity,
        TableServiceOptions $options = null
    ) {
        return $this->putOrMergeEntityAsyncImpl(
            $table,
            $entity,
            Resources::HTTP_MERGE,
            false,
            $options
        );
    }

public function insertOrMergeEntityAsync ( $ table , Entity $ entity , TableServiceOptions $ options = null ) { return $ this -> putOrMergeEntityAsyncImpl ( $ table , $ entity , Resources :: HTTP_MERGE , false , $ options ) ; }

Creates promise to update an existing entity or inserts a new entity if
it does not exist in the table.

@param string              $table   name of the table
@param Entity              $entity  table entity
@param TableServiceOptions $options optional parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see http://msdn.microsoft.com/en-us/library/windowsazure/hh452241.aspx

Creates promise to update an existing entity or inserts a new entity if it does not exist in the table .


public function insertOrReplaceEntity(
        $table,
        Entity $entity,
        TableServiceOptions $options = null
    ) {
        return $this->insertOrReplaceEntityAsync(
            $table,
            $entity,
            $options
        )->wait();
    }

public function insertOrReplaceEntity ( $ table , Entity $ entity , TableServiceOptions $ options = null ) { return $ this -> insertOrReplaceEntityAsync ( $ table , $ entity , $ options ) -> wait ( ) ; }

Replaces an existing entity or inserts a new entity if it does not exist in
the table.

@param string              $table   name of the table
@param Entity              $entity  table entity
@param TableServiceOptions $options optional parameters

@return UpdateEntityResult

@see http://msdn.microsoft.com/en-us/library/windowsazure/hh452242.aspx

Replaces an existing entity or inserts a new entity if it does not exist in the table .


public function insertOrReplaceEntityAsync(
        $table,
        Entity $entity,
        TableServiceOptions $options = null
    ) {
        return $this->putOrMergeEntityAsyncImpl(
            $table,
            $entity,
            Resources::HTTP_PUT,
            false,
            $options
        );
    }

public function insertOrReplaceEntityAsync ( $ table , Entity $ entity , TableServiceOptions $ options = null ) { return $ this -> putOrMergeEntityAsyncImpl ( $ table , $ entity , Resources :: HTTP_PUT , false , $ options ) ; }

Creates a promise to replace an existing entity or inserts a new entity if it does not exist in the table.

@param string              $table   name of the table
@param Entity              $entity  table entity
@param TableServiceOptions $options optional parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see http://msdn.microsoft.com/en-us/library/windowsazure/hh452242.aspx

Creates a promise to replace an existing entity or inserts a new entity if it does not exist in the table .


public function updateEntity(
        $table,
        Entity $entity,
        TableServiceOptions $options = null
    ) {
        return $this->updateEntityAsync($table, $entity, $options)->wait();
    }

public function updateEntity ( $ table , Entity $ entity , TableServiceOptions $ options = null ) { return $ this -> updateEntityAsync ( $ table , $ entity , $ options ) -> wait ( ) ; }

Updates an existing entity in a table. The Update Entity operation replaces
the entire entity and can be used to remove properties.

@param string              $table   The table name.
@param Entity              $entity  The table entity.
@param TableServiceOptions $options The optional parameters.

@return UpdateEntityResult

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd179427.aspx

Updates an existing entity in a table . The Update Entity operation replaces the entire entity and can be used to remove properties .


public function updateEntityAsync(
        $table,
        Entity $entity,
        TableServiceOptions $options = null
    ) {
        return $this->putOrMergeEntityAsyncImpl(
            $table,
            $entity,
            Resources::HTTP_PUT,
            true,
            $options
        );
    }

public function updateEntityAsync ( $ table , Entity $ entity , TableServiceOptions $ options = null ) { return $ this -> putOrMergeEntityAsyncImpl ( $ table , $ entity , Resources :: HTTP_PUT , true , $ options ) ; }

Creates promise to update an existing entity in a table. The Update Entity
operation replaces the entire entity and can be used to remove properties.

@param string              $table   The table name.
@param Entity              $entity  The table entity.
@param TableServiceOptions $options The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd179427.aspx

Creates promise to update an existing entity in a table . The Update Entity operation replaces the entire entity and can be used to remove properties .


public function mergeEntity(
        $table,
        Entity $entity,
        TableServiceOptions $options = null
    ) {
        return $this->mergeEntityAsync($table, $entity, $options)->wait();
    }

public function mergeEntity ( $ table , Entity $ entity , TableServiceOptions $ options = null ) { return $ this -> mergeEntityAsync ( $ table , $ entity , $ options ) -> wait ( ) ; }

Updates an existing entity by updating the entity's properties. This operation
does not replace the existing entity, as the updateEntity operation does.

@param string              $table   The table name.
@param Entity              $entity  The table entity.
@param TableServiceOptions $options The optional parameters.

@return Models\UpdateEntityResult

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd179392.aspx

Updates an existing entity by updating the entity s properties . This operation does not replace the existing entity as the updateEntity operation does .


public function mergeEntityAsync(
        $table,
        Entity $entity,
        TableServiceOptions $options = null
    ) {
        return $this->putOrMergeEntityAsyncImpl(
            $table,
            $entity,
            Resources::HTTP_MERGE,
            true,
            $options
        );
    }

public function mergeEntityAsync ( $ table , Entity $ entity , TableServiceOptions $ options = null ) { return $ this -> putOrMergeEntityAsyncImpl ( $ table , $ entity , Resources :: HTTP_MERGE , true , $ options ) ; }

Creates promise to update an existing entity by updating the entity's
properties. This operation does not replace the existing entity, as the
updateEntity operation does.

@param string              $table   The table name.
@param Entity              $entity  The table entity.
@param TableServiceOptions $options The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd179392.aspx

Creates promise to update an existing entity by updating the entity s properties . This operation does not replace the existing entity as the updateEntity operation does .


public function deleteEntity(
        $table,
        $partitionKey,
        $rowKey,
        DeleteEntityOptions $options = null
    ) {
        $this->deleteEntityAsync($table, $partitionKey, $rowKey, $options)->wait();
    }

public function deleteEntity ( $ table , $ partitionKey , $ rowKey , DeleteEntityOptions $ options = null ) { $ this -> deleteEntityAsync ( $ table , $ partitionKey , $ rowKey , $ options ) -> wait ( ) ; }

Deletes an existing entity in a table.

@param string              $table        The name of the table.
@param string              $partitionKey The entity partition key.
@param string              $rowKey       The entity row key.
@param DeleteEntityOptions $options      The optional parameters.

@return void

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd135727.aspx


public function deleteEntityAsync(
        $table,
        $partitionKey,
        $rowKey,
        DeleteEntityOptions $options = null
    ) {
        $context = $this->constructDeleteEntityContext(
            $table,
            $partitionKey,
            $rowKey,
            $options
        );

        return $this->sendContextAsync($context);
    }

public function deleteEntityAsync ( $ table , $ partitionKey , $ rowKey , DeleteEntityOptions $ options = null ) { $ context = $ this -> constructDeleteEntityContext ( $ table , $ partitionKey , $ rowKey , $ options ) ; return $ this -> sendContextAsync ( $ context ) ; }

Creates promise to delete an existing entity in a table.

@param string              $table        The name of the table.
@param string              $partitionKey The entity partition key.
@param string              $rowKey       The entity row key.
@param DeleteEntityOptions $options      The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd135727.aspx

Creates promise to delete an existing entity in a table .


public function getEntity(
        $table,
        $partitionKey,
        $rowKey,
        GetEntityOptions $options = null
    ) {
        return $this->getEntityAsync(
            $table,
            $partitionKey,
            $rowKey,
            $options
        )->wait();
    }

public function getEntity ( $ table , $ partitionKey , $ rowKey , GetEntityOptions $ options = null ) { return $ this -> getEntityAsync ( $ table , $ partitionKey , $ rowKey , $ options ) -> wait ( ) ; }

Gets table entity.

@param string                $table        The name of the table.
@param string                $partitionKey The entity partition key.
@param string                $rowKey       The entity row key.
@param GetEntityOptions|null $options      The optional parameters.

@return GetEntityResult

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd179421.aspx


public function getEntityAsync(
        $table,
        $partitionKey,
        $rowKey,
        GetEntityOptions $options = null
    ) {
        Validate::canCastAsString($table, 'table');
        Validate::notNullOrEmpty($table, 'table');
        Validate::isTrue(!is_null($partitionKey), Resources::NULL_TABLE_KEY_MSG);
        Validate::isTrue(!is_null($rowKey), Resources::NULL_TABLE_KEY_MSG);

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $queryParams = array();
        $path        = $this->getEntityPath($table, $partitionKey, $rowKey);

        if (is_null($options)) {
            $options = new GetEntityOptions();
        }

        // TODO: support payload format options
        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_TYPE,
            Resources::JSON_CONTENT_TYPE
        );
        $this->addOptionalHeader(
            $headers,
            Resources::ACCEPT_HEADER,
            $options->getAccept()
        );

        $context = new HttpCallContext();
        $context->setHeaders($headers);
        $context->setMethod($method);
        $context->setPath($path);
        $context->setQueryParameters($queryParams);
        $context->setStatusCodes(array(Resources::STATUS_OK));
        $context->setServiceOptions($options);

        $odataSerializer = $this->odataSerializer;

        return $this->sendContextAsync($context)->then(
            function ($response) use ($odataSerializer) {
                return GetEntityResult::create(
                    $response->getBody(),
                    $odataSerializer
                );
            },
            null
        );
    }

public
function
getEntityAsync
(
$
table
,
$
partitionKey
,
$
rowKey
,
GetEntityOptions
$
options
=
)
{
Validate
::
canCastAsString
(
$
table
,
'table'
)
;
Validate
::
notNullOrEmpty
(
$
table
,
'table'
)
;
Validate
::
isTrue
(
!
is_null
(
$
partitionKey
)
,
Resources
::
NULL_TABLE_KEY_MSG
)
;
Validate
::
isTrue
(
!
is_null
(
$
rowKey
)
,
Resources
::
NULL_TABLE_KEY_MSG
)
;
$
method
=
Resources
::
HTTP_GET
;
$
headers
=
array
(
)
;
$
queryParams
=
array
(
)
;
$
path
=
$
this
->
getEntityPath
(
$
table
,
$
partitionKey
,
$
rowKey
)
;
if
(
is_null
(
$
options
)
)
{
$
options
=
new
GetEntityOptions
(
)
;
}
// TODO: support payload format options
$
this
->
addOptionalHeader
(
$
headers
,
Resources
::
CONTENT_TYPE
,
Resources
::
JSON_CONTENT_TYPE
)
;
$
this
->
addOptionalHeader
(
$
headers
,
Resources
::
ACCEPT_HEADER
,
$
options
->
getAccept
(
)
)
;
$
context
=
new
HttpCallContext
(
)
;
$
context
->
setHeaders
(
$
headers
)
;
$
context
->
setMethod
(
$
method
)
;
$
context
->
setPath
(
$
path
)
;
$
context
->
setQueryParameters
(
$
queryParams
)
;
$
context
->
setStatusCodes
(
array
(
Resources
::
STATUS_OK
)
)
;
$
context
->
setServiceOptions
(
$
options
)
;
$
odataSerializer
=
$
this
->
odataSerializer
;
return
$
this
->
sendContextAsync
(
$
context
)
->
then
(
function
(
$
response
)
use
(
$
odataSerializer
)
{
return
GetEntityResult
::
create
(
$
response
->
getBody
(
)
,
$
odataSerializer
)
;
}
,
)
;
}

Creates promise to get table entity.

@param string                $table        The name of the table.
@param string                $partitionKey The entity partition key.
@param string                $rowKey       The entity row key.
@param GetEntityOptions|null $options      The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see http://msdn.microsoft.com/en-us/library/windowsazure/dd179421.aspx


public function batch(
        Models\BatchOperations $batchOperations,
        Models\TableServiceOptions $options = null
    ) {
        return $this->batchAsync($batchOperations, $options)->wait();
    }

public function batch ( Models \ BatchOperations $ batchOperations , Models \ TableServiceOptions $ options = null ) { return $ this -> batchAsync ( $ batchOperations , $ options ) -> wait ( ) ; }

Does batch of operations on the table service.

@param BatchOperations     $batchOperations The operations to apply.
@param TableServiceOptions $options         The optional parameters.

@return BatchResult

Does batch of operations on the table service .


public function batchAsync(
        Models\BatchOperations $batchOperations,
        Models\TableServiceOptions $options = null
    ) {
        Validate::notNullOrEmpty($batchOperations, 'batchOperations');

        $method      = Resources::HTTP_POST;
        $operations  = $batchOperations->getOperations();
        $contexts    = $this->createOperationsContexts($operations);
        $mime        = $this->createBatchRequestBody($operations, $contexts);
        $body        = $mime['body'];
        $headers     = $mime['headers'];
        $postParams  = array();
        $queryParams = array();
        $path        = '$batch';

        if (is_null($options)) {
            $options = new TableServiceOptions();
        }

        $odataSerializer = $this->odataSerializer;
        $mimeSerializer = $this->mimeSerializer;

        $options->setLocationMode(LocationMode::PRIMARY_ONLY);

        $this->addOptionalHeader(
            $headers,
            Resources::ACCEPT_HEADER,
            Resources::JSON_FULL_METADATA_CONTENT_TYPE
        );

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_ACCEPTED,
            $body,
            $options
        )->then(function ($response) use (
            $operations,
            $contexts,
            $odataSerializer,
            $mimeSerializer
        ) {
            return BatchResult::create(
                $response->getBody(),
                $operations,
                $contexts,
                $odataSerializer,
                $mimeSerializer
            );
        }, null);
    }

public function batchAsync ( Models \ BatchOperations $ batchOperations , Models \ TableServiceOptions $ options = null ) { Validate :: notNullOrEmpty ( $ batchOperations , 'batchOperations' ) ; $ method = Resources :: HTTP_POST ; $ operations = $ batchOperations -> getOperations ( ) ; $ contexts = $ this -> createOperationsContexts ( $ operations ) ; $ mime = $ this -> createBatchRequestBody ( $ operations , $ contexts ) ; $ body = $ mime [ 'body' ] ; $ headers = $ mime [ 'headers' ] ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = '$batch' ; if ( is_null ( $ options ) ) { $ options = new TableServiceOptions ( ) ; } $ odataSerializer = $ this -> odataSerializer ; $ mimeSerializer = $ this -> mimeSerializer ; $ options -> setLocationMode ( LocationMode :: PRIMARY_ONLY ) ; $ this -> addOptionalHeader ( $ headers , Resources :: ACCEPT_HEADER , Resources :: JSON_FULL_METADATA_CONTENT_TYPE ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_ACCEPTED , $ body , $ options ) -> then ( function ( $ response ) use ( $ operations , $ contexts , $ odataSerializer , $ mimeSerializer ) { return BatchResult :: create ( $ response -> getBody ( ) , $ operations , $ contexts , $ odataSerializer , $ mimeSerializer ) ; } , null ) ; }

Creates promise that does batch of operations on the table service.

@param BatchOperations     $batchOperations The operations to apply.
@param TableServiceOptions $options         The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

Creates promise that does batch of operations on the table service .


public static function create(array $parsedResponse, $location = '')
    {
        $result               = new ListDirectoriesAndFilesResult();
        $serviceEndpoint      = Utilities::tryGetKeysChainValue(
            $parsedResponse,
            Resources::XTAG_ATTRIBUTES,
            Resources::XTAG_SERVICE_ENDPOINT
        );
        $result->setAccountName(Utilities::tryParseAccountNameFromUrl(
            $serviceEndpoint
        ));

        $nextMarker = Utilities::tryGetValue(
            $parsedResponse,
            Resources::QP_NEXT_MARKER
        );

        if ($nextMarker != null) {
            $result->setContinuationToken(
                new MarkerContinuationToken(
                    $nextMarker,
                    $location
                )
            );
        }

        $result->setMaxResults(Utilities::tryGetValue(
            $parsedResponse,
            Resources::QP_MAX_RESULTS
        ));

        $result->setMarker(Utilities::tryGetValue(
            $parsedResponse,
            Resources::QP_MARKER
        ));

        $entries = Utilities::tryGetValue(
            $parsedResponse,
            Resources::QP_ENTRIES
        );

        if (empty($entries)) {
            $result->setDirectories(array());
            $result->setFiles(array());
        } else {
            $directoriesArray = Utilities::tryGetValue(
                $entries,
                Resources::QP_DIRECTORY
            );
            $filesArray = Utilities::tryGetValue(
                $entries,
                Resources::QP_FILE
            );

            $directories = array();
            $files = array();

            if ($directoriesArray != null) {
                if (array_key_exists(Resources::QP_NAME, $directoriesArray)) {
                    $directoriesArray = [$directoriesArray];
                }
                foreach ($directoriesArray as $directoryArray) {
                    $directories[] = Directory::create($directoryArray);
                }
            }

            if ($filesArray != null) {
                if (array_key_exists(Resources::QP_NAME, $filesArray)) {
                    $filesArray = [$filesArray];
                }
                foreach ($filesArray as $fileArray) {
                    $files[] = File::create($fileArray);
                }
            }

            $result->setDirectories($directories);
            $result->setFiles($files);
        }

        return $result;
    }

public static function create ( array $ parsedResponse , $ location = '' ) { $ result = new ListDirectoriesAndFilesResult ( ) ; $ serviceEndpoint = Utilities :: tryGetKeysChainValue ( $ parsedResponse , Resources :: XTAG_ATTRIBUTES , Resources :: XTAG_SERVICE_ENDPOINT ) ; $ result -> setAccountName ( Utilities :: tryParseAccountNameFromUrl ( $ serviceEndpoint ) ) ; $ nextMarker = Utilities :: tryGetValue ( $ parsedResponse , Resources :: QP_NEXT_MARKER ) ; if ( $ nextMarker != null ) { $ result -> setContinuationToken ( new MarkerContinuationToken ( $ nextMarker , $ location ) ) ; } $ result -> setMaxResults ( Utilities :: tryGetValue ( $ parsedResponse , Resources :: QP_MAX_RESULTS ) ) ; $ result -> setMarker ( Utilities :: tryGetValue ( $ parsedResponse , Resources :: QP_MARKER ) ) ; $ entries = Utilities :: tryGetValue ( $ parsedResponse , Resources :: QP_ENTRIES ) ; if ( empty ( $ entries ) ) { $ result -> setDirectories ( array ( ) ) ; $ result -> setFiles ( array ( ) ) ; } else { $ directoriesArray = Utilities :: tryGetValue ( $ entries , Resources :: QP_DIRECTORY ) ; $ filesArray = Utilities :: tryGetValue ( $ entries , Resources :: QP_FILE ) ; $ directories = array ( ) ; $ files = array ( ) ; if ( $ directoriesArray != null ) { if ( array_key_exists ( Resources :: QP_NAME , $ directoriesArray ) ) { $ directoriesArray = [ $ directoriesArray ] ; } foreach ( $ directoriesArray as $ directoryArray ) { $ directories [ ] = Directory :: create ( $ directoryArray ) ; } } if ( $ filesArray != null ) { if ( array_key_exists ( Resources :: QP_NAME , $ filesArray ) ) { $ filesArray = [ $ filesArray ] ; } foreach ( $ filesArray as $ fileArray ) { $ files [ ] = File :: create ( $ fileArray ) ; } } $ result -> setDirectories ( $ directories ) ; $ result -> setFiles ( $ files ) ; } return $ result ; }

Creates ListDirectoriesAndFilesResult object from parsed XML response.

@param array  $parsedResponse XML response parsed into array.
@param string $location       Contains the location for the previous
request.

@internal

@return ListDirectoriesAndFilesResult

Creates ListDirectoriesAndFilesResult object from parsed XML response .


protected function setDirectories(array $directories)
    {
        $this->directories = array();
        foreach ($directories as $directory) {
            $this->directories[] = clone $directory;
        }
    }

protected function setDirectories ( array $ directories ) { $ this -> directories = array ( ) ; foreach ( $ directories as $ directory ) { $ this -> directories [ ] = clone $ directory ; } }

Sets Directories.

@param array $directories list of directories.

@return void


protected function setFiles(array $files)
    {
        $this->files = array();
        foreach ($files as $file) {
            $this->files[] = clone $file;
        }
    }

protected function setFiles ( array $ files ) { $ this -> files = array ( ) ; foreach ( $ files as $ file ) { $ this -> files [ ] = clone $ file ; } }

Sets files.

@param array $files list of files.

@return void


public static function create(array $parsed)
    {
        $result = new Directory();
        $name = Utilities::tryGetValue($parsed, Resources::QP_NAME);
        $result->setName($name);

        return $result;
    }

public static function create ( array $ parsed ) { $ result = new Directory ( ) ; $ name = Utilities :: tryGetValue ( $ parsed , Resources :: QP_NAME ) ; $ result -> setName ( $ name ) ; return $ result ; }

Creates a Directory object using the parsed array.

@param  array $parsed The parsed array that contains the object information.

@return Directory

Creates a Directory object using the parsed array .


public static function create(array $headers)
    {
        $result = new UpdateEntityResult();
        $result->setETag(
            Utilities::tryGetValueInsensitive(Resources::ETAG, $headers)
        );

        return $result;
    }

public static function create ( array $ headers ) { $ result = new UpdateEntityResult ( ) ; $ result -> setETag ( Utilities :: tryGetValueInsensitive ( Resources :: ETAG , $ headers ) ) ; return $ result ; }

Creates UpdateEntityResult from HTTP response headers.

@param array $headers The HTTP response headers.

@internal

@return UpdateEntityResult

Creates UpdateEntityResult from HTTP response headers .


public function setQueryParameters(array $queryParams)
    {
        $this->_queryParams = array();
        foreach ($queryParams as $key => $value) {
            $this->addQueryParameter($key, $value);
        }
    }

public function setQueryParameters ( array $ queryParams ) { $ this -> _queryParams = array ( ) ; foreach ( $ queryParams as $ key => $ value ) { $ this -> addQueryParameter ( $ key , $ value ) ; } }

Sets queryParams.

Ignores the query variable if its value is empty.

@param array $queryParams The queryParams value.

@return void


public function setStatusCodes(array $statusCodes)
    {
        $this->_statusCodes = array();
        foreach ($statusCodes as $value) {
            $this->addStatusCode($value);
        }
    }

public function setStatusCodes ( array $ statusCodes ) { $ this -> _statusCodes = array ( ) ; foreach ( $ statusCodes as $ value ) { $ this -> addStatusCode ( $ value ) ; } }

Sets statusCodes.

@param array $statusCodes The statusCodes value.

@return void


public function removeHeader($name)
    {
        Validate::canCastAsString($name, 'name');
        Validate::notNullOrEmpty($name, 'name');

        unset($this->_headers[$name]);
    }

public function removeHeader ( $ name ) { Validate :: canCastAsString ( $ name , 'name' ) ; Validate :: notNullOrEmpty ( $ name , 'name' ) ; unset ( $ this -> _headers [ $ name ] ) ; }

Removes header from the HTTP request headers.

@param string $name The HTTP header name.

@return void

Removes header from the HTTP request headers .


public function addHistory(array $entry)
    {
        if ($this->path !== '') {
            $this->appendNewEntryToPath($entry);
        } else {
            Validate::isTrue(
                array_key_exists('request', $entry) &&
                array_key_exists('options', $entry) &&
                (array_key_exists('response', $entry) ||
                array_key_exists('reason', $entry)),
                'Given history entry not in correct format'
            );
            $this->history[] = $entry;
        }
        ++$this->count;
    }

Add an entry to history

@param array $entry the entry to be added.


private function appendNewEntryToPath(array $entry)
    {
        $entryNoString = "Entry " . $this->count;
        $delimiter = str_pad(
            $entryNoString,
            self::TITLE_LENGTH,
            '-',
            STR_PAD_BOTH
        ) . PHP_EOL;
        $entryString = $delimiter;
        $entryString .= sprintf(
            "Time: %s\n",
            (new \DateTime("now", new \DateTimeZone('UTC')))->format('Y-m-d H:i:s')
        );
        $entryString .= MessageSerializer::objectSerialize($entry['request']);
        if (array_key_exists('reason', $entry)) {
            $entryString .= MessageSerializer::objectSerialize($entry['reason']);
        } elseif (array_key_exists('response', $entry)) {
            $entryString .= MessageSerializer::objectSerialize($entry['response']);
        }

        $entryString .= $delimiter;

        Utilities::appendToFile($this->path, $entryString);
    }

private
function
appendNewEntryToPath
(
array
$
entry
)
{
$
entryNoString
=
"Entry "
.
$
this
->
count
;
$
delimiter
=
str_pad
(
$
entryNoString
,
self
::
TITLE_LENGTH
,
'-'
,
STR_PAD_BOTH
)
.
PHP_EOL
;
$
entryString
=
$
delimiter
;
$
entryString
.=
sprintf
(
"Time: %s\n"
,
(
new
\
DateTime
(
"now"
,
new
\
DateTimeZone
(
'UTC'
)
)
)
->
format
(
'Y-m-d H:i:s'
)
)
;
$
entryString
.=
MessageSerializer
::
objectSerialize
(
$
entry
[
'request'
]
)
;
if
(
array_key_exists
(
'reason'
,
$
entry
)
)
{
$
entryString
.=
MessageSerializer
::
objectSerialize
(
$
entry
[
'reason'
]
)
;
}
elseif
(
array_key_exists
(
'response'
,
$
entry
)
)
{
$
entryString
.=
MessageSerializer
::
objectSerialize
(
$
entry
[
'response'
]
)
;
}
$
entryString
.=
$
delimiter
;
Utilities
::
appendToFile
(
$
this
->
path
,
$
entryString
)
;
}

Append the new entry to saved file path.

@param array $entry the entry to be added.

@return void

Append the new entry to saved file path .


public static function create(array $headers, array $entries)
    {
        $result  = new QueryTablesResult();
        $headers = array_change_key_case($headers);

        $result->setTables($entries);

        $nextTableName = Utilities::tryGetValue(
            $headers,
            Resources::X_MS_CONTINUATION_NEXTTABLENAME
        );

        if ($nextTableName != null) {
            $result->setContinuationToken(
                new TableContinuationToken(
                    $nextTableName,
                    '',
                    '',
                    Utilities::getLocationFromHeaders($headers)
                )
            );
        }

        return $result;
    }

public static function create ( array $ headers , array $ entries ) { $ result = new QueryTablesResult ( ) ; $ headers = array_change_key_case ( $ headers ) ; $ result -> setTables ( $ entries ) ; $ nextTableName = Utilities :: tryGetValue ( $ headers , Resources :: X_MS_CONTINUATION_NEXTTABLENAME ) ; if ( $ nextTableName != null ) { $ result -> setContinuationToken ( new TableContinuationToken ( $ nextTableName , '' , '' , Utilities :: getLocationFromHeaders ( $ headers ) ) ) ; } return $ result ; }

Creates new QueryTablesResult object

@param array $headers The HTTP response headers
@param array $entries The table entriess

@internal

@return QueryTablesResult


public static function create(array $parsedResponse = null)
    {
        $result        = new ListMessagesResult();
        $queueMessages = array();

        if (!empty($parsedResponse)) {
            $rawMessages = Utilities::getArray($parsedResponse['QueueMessage']);
            foreach ($rawMessages as $value) {
                $message = QueueMessage::createFromListMessages($value);

                $queueMessages[] = $message;
            }
        }
        $result->setQueueMessages($queueMessages);

        return $result;
    }

public static function create ( array $ parsedResponse = null ) { $ result = new ListMessagesResult ( ) ; $ queueMessages = array ( ) ; if ( ! empty ( $ parsedResponse ) ) { $ rawMessages = Utilities :: getArray ( $ parsedResponse [ 'QueueMessage' ] ) ; foreach ( $ rawMessages as $ value ) { $ message = QueueMessage :: createFromListMessages ( $ value ) ; $ queueMessages [ ] = $ message ; } } $ result -> setQueueMessages ( $ queueMessages ) ; return $ result ; }

Creates ListMessagesResult object from parsed XML response.

@param array $parsedResponse XML response parsed into array.

@internal

@return ListMessagesResult

Creates ListMessagesResult object from parsed XML response .


protected function setQueueMessages(array $queueMessages)
    {
        $this->_queueMessages = array();

        foreach ($queueMessages as $value) {
            $this->_queueMessages[] = clone $value;
        }
    }

protected function setQueueMessages ( array $ queueMessages ) { $ this -> _queueMessages = array ( ) ; foreach ( $ queueMessages as $ value ) { $ this -> _queueMessages [ ] = clone $ value ; } }

Sets queueMessages field.

@param array $queueMessages value to use.

@internal

@return void


private static function _init()
    {
        if (!self::$_isInitialized) {
            self::$_sources = array();

            // Get list of default connection string sources.
            $default = ConnectionStringSource::getDefaultSources();
            foreach ($default as $name => $provider) {
                self::$_sources[$name] = $provider;
            }

            self::$_isInitialized = true;
        }
    }

Initializes the connection string source providers.

@return void

Initializes the connection string source providers .


public static function isValidHostname($hostname)
    {
        if (defined('FILTER_VALIDATE_DOMAIN')) {
            $isValid = filter_var($hostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
        } else {
            // (less accurate) fallback for PHP < 7.0
            $isValid = preg_match('/^[a-z0-9_-]+(\.[a-z0-9_-]+)*$/i', $hostname);
        }

        if ($isValid) {
            return true;
        } else {
            throw new \RuntimeException(
                sprintf(Resources::INVALID_CONFIG_HOSTNAME, $hostname)
            );
        }
    }

Throws an exception if the string is not of a valid hostname.

@param string $hostname String to check.

@throws \InvalidArgumentException

@return boolean

Throws an exception if the string is not of a valid hostname .


public static function isValidUri($uri)
    {
        $isValid = filter_var($uri, FILTER_VALIDATE_URL);

        if ($isValid) {
            return true;
        } else {
            throw new \RuntimeException(
                sprintf(Resources::INVALID_CONFIG_URI, $uri)
            );
        }
    }

public static function isValidUri ( $ uri ) { $ isValid = filter_var ( $ uri , FILTER_VALIDATE_URL ) ; if ( $ isValid ) { return true ; } else { throw new \ RuntimeException ( sprintf ( Resources :: INVALID_CONFIG_URI , $ uri ) ) ; } }

Throws exception if the string is not of a valid uri.

@param string $uri String to check.

@throws \InvalidArgumentException

@return boolean

Throws exception if the string is not of a valid uri .


public static function methodExists($objectInstance, $method, $name)
    {
        Validate::canCastAsString($method, 'method');
        Validate::notNull($objectInstance, 'objectInstance');
        Validate::isObject($objectInstance, 'objectInstance');

        if (method_exists($objectInstance, $method)) {
            return true;
        } else {
            throw new \InvalidArgumentException(
                sprintf(
                    Resources::ERROR_METHOD_NOT_FOUND,
                    $method,
                    $name
                )
            );
        }
    }

public static function methodExists ( $ objectInstance , $ method , $ name ) { Validate :: canCastAsString ( $ method , 'method' ) ; Validate :: notNull ( $ objectInstance , 'objectInstance' ) ; Validate :: isObject ( $ objectInstance , 'objectInstance' ) ; if ( method_exists ( $ objectInstance , $ method ) ) { return true ; } else { throw new \ InvalidArgumentException ( sprintf ( Resources :: ERROR_METHOD_NOT_FOUND , $ method , $ name ) ) ; } }

Validate if method exists in object

@param object $objectInstance An object that requires method existing
validation
@param string $method         Method name
@param string $name           The parameter name

@return boolean


public static function isDateString($value, $name)
    {
        Validate::canCastAsString($value, 'value');

        try {
            new \DateTime($value);
            return true;
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(
                sprintf(
                    Resources::ERROR_INVALID_DATE_STRING,
                    $name,
                    $value
                )
            );
        }
    }

public static function isDateString ( $ value , $ name ) { Validate :: canCastAsString ( $ value , 'value' ) ; try { new \ DateTime ( $ value ) ; return true ; } catch ( \ Exception $ e ) { throw new \ InvalidArgumentException ( sprintf ( Resources :: ERROR_INVALID_DATE_STRING , $ name , $ value ) ) ; } }

Validate if string is date formatted

@param string $value Value to validate
@param string $name  Name of parameter to insert in erro message

@throws \InvalidArgumentException

@return boolean


public static function hasKey($key, $name, array $array)
    {
        Validate::isArray($array, $name);

        if (!array_key_exists($key, $array)) {
            throw new \UnexpectedValueException(
                sprintf(
                    Resources::INVALID_VALUE_MSG,
                    $name,
                    sprintf(Resources::ERROR_KEY_NOT_EXIST, $key)
                )
            );
        }

        return true;
    }

public static function hasKey ( $ key , $ name , array $ array ) { Validate :: isArray ( $ array , $ name ) ; if ( ! array_key_exists ( $ key , $ array ) ) { throw new \ UnexpectedValueException ( sprintf ( Resources :: INVALID_VALUE_MSG , $ name , sprintf ( Resources :: ERROR_KEY_NOT_EXIST , $ key ) ) ) ; } return true ; }

Validate if the provided array has key, throw exception otherwise.

@param  string  $key   The key to be searched.
@param  string  $name  The name of the array.
@param  array   $array The array to be validated.

@throws \UnexpectedValueException
@throws \InvalidArgumentException

@return  boolean

Validate if the provided array has key throw exception otherwise .


public function getRangeString()
    {
        $rangeString = '';

        $rangeString .= ('bytes=' . $this->start . '-');
        if ($this->end != null) {
            $rangeString .= $this->end;
        }

        return $rangeString;
    }

public function getRangeString ( ) { $ rangeString = '' ; $ rangeString .= ( 'bytes=' . $ this -> start . '-' ) ; if ( $ this -> end != null ) { $ rangeString .= $ this -> end ; } return $ rangeString ; }

Constructs the range string according to the set start and end

@return string


public function listQueuesAsync(ListQueuesOptions $options = null)
    {
        $method      = Resources::HTTP_GET;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = Resources::EMPTY_STRING;

        if (is_null($options)) {
            $options = new ListQueuesOptions();
        }

        $maxResults = $options->getMaxResults();
        $include    = $options->getIncludeMetadata();
        $include    = $include ? 'metadata' : null;
        $prefix     = $options->getPrefix();
        $marker     = $options->getNextMarker();

        $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'list');
        $this->addOptionalQueryParam($queryParams, Resources::QP_PREFIX, $prefix);
        $this->addOptionalQueryParam($queryParams, Resources::QP_MARKER, $marker);
        $this->addOptionalQueryParam($queryParams, Resources::QP_INCLUDE, $include);
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_MAX_RESULTS,
            $maxResults
        );

        $dataSerializer = $this->dataSerializer;

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) use ($dataSerializer) {
            $parsed = $dataSerializer->unserialize($response->getBody());
            return ListQueuesResult::create(
                $parsed,
                Utilities::getLocationFromHeaders($response->getHeaders())
            );
        }, null);
    }

public function listQueuesAsync ( ListQueuesOptions $ options = null ) { $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = Resources :: EMPTY_STRING ; if ( is_null ( $ options ) ) { $ options = new ListQueuesOptions ( ) ; } $ maxResults = $ options -> getMaxResults ( ) ; $ include = $ options -> getIncludeMetadata ( ) ; $ include = $ include ? 'metadata' : null ; $ prefix = $ options -> getPrefix ( ) ; $ marker = $ options -> getNextMarker ( ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , 'list' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_PREFIX , $ prefix ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_MARKER , $ marker ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_INCLUDE , $ include ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_MAX_RESULTS , $ maxResults ) ; $ dataSerializer = $ this -> dataSerializer ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) use ( $ dataSerializer ) { $ parsed = $ dataSerializer -> unserialize ( $ response -> getBody ( ) ) ; return ListQueuesResult :: create ( $ parsed , Utilities :: getLocationFromHeaders ( $ response -> getHeaders ( ) ) ) ; } , null ) ; }

Creates promise to list all queues in the storage account.

@param ListQueuesOptions $options The optional list queue options.

@return \GuzzleHttp\Promise\PromiseInterface

Creates promise to list all queues in the storage account .


public function clearMessages($queueName, QueueServiceOptions $options = null)
    {
        $this->clearMessagesAsync($queueName, $options)->wait();
    }

public function clearMessages ( $ queueName , QueueServiceOptions $ options = null ) { $ this -> clearMessagesAsync ( $ queueName , $ options ) -> wait ( ) ; }

Clears all messages from the queue.

If a queue contains a large number of messages, Clear Messages may time out
before all messages have been deleted. In this case the Queue service will
return status code 500 (Internal Server Error), with the additional error
code OperationTimedOut. If the operation times out, the client should
continue to retry Clear Messages until it succeeds, to ensure that all
messages have been deleted.

@param string              $queueName The name of the queue.
@param QueueServiceOptions $options   The optional parameters.

@return void


public function createMessage(
        $queueName,
        $messageText,
        CreateMessageOptions $options = null
    ) {
        return $this->createMessageAsync($queueName, $messageText, $options)->wait();
    }

public function createMessage ( $ queueName , $ messageText , CreateMessageOptions $ options = null ) { return $ this -> createMessageAsync ( $ queueName , $ messageText , $ options ) -> wait ( ) ; }

Adds a message to the queue and optionally sets a visibility timeout
for the message.

@param string               $queueName   The name of the queue.
@param string               $messageText The message contents.
@param CreateMessageOptions $options     The optional parameters.

@return CreateMessageResult

Adds a message to the queue and optionally sets a visibility timeout for the message .


public function createMessageAsync(
        $queueName,
        $messageText,
        CreateMessageOptions $options = null
    ) {
        Validate::canCastAsString($queueName, 'queueName');
        Validate::notNullOrEmpty($queueName, 'queueName');
        Validate::canCastAsString($messageText, 'messageText');

        $method      = Resources::HTTP_POST;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $queueName . '/messages';
        $body        = Resources::EMPTY_STRING;
        $message     = new QueueMessage();
        $message->setMessageText($messageText);
        $body = $message->toXml($this->dataSerializer);

        if (is_null($options)) {
            $options = new CreateMessageOptions();
        }

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_TYPE,
            Resources::URL_ENCODED_CONTENT_TYPE
        );

        $visibility = $options->getVisibilityTimeoutInSeconds();
        $timeToLive = $options->getTimeToLiveInSeconds();

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_VISIBILITY_TIMEOUT,
            $visibility
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_MESSAGE_TTL,
            $timeToLive
        );

        $options->setLocationMode(LocationMode::PRIMARY_ONLY);

        $dataSerializer = $this->dataSerializer;

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_CREATED,
            $body,
            $options
        )->then(function ($response) use ($dataSerializer) {
            $parsed = $dataSerializer->unserialize($response->getBody());
            return CreateMessageResult::create($parsed);
        }, null);
    }

public function createMessageAsync ( $ queueName , $ messageText , CreateMessageOptions $ options = null ) { Validate :: canCastAsString ( $ queueName , 'queueName' ) ; Validate :: notNullOrEmpty ( $ queueName , 'queueName' ) ; Validate :: canCastAsString ( $ messageText , 'messageText' ) ; $ method = Resources :: HTTP_POST ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ queueName . '/messages' ; $ body = Resources :: EMPTY_STRING ; $ message = new QueueMessage ( ) ; $ message -> setMessageText ( $ messageText ) ; $ body = $ message -> toXml ( $ this -> dataSerializer ) ; if ( is_null ( $ options ) ) { $ options = new CreateMessageOptions ( ) ; } $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_TYPE , Resources :: URL_ENCODED_CONTENT_TYPE ) ; $ visibility = $ options -> getVisibilityTimeoutInSeconds ( ) ; $ timeToLive = $ options -> getTimeToLiveInSeconds ( ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_VISIBILITY_TIMEOUT , $ visibility ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_MESSAGE_TTL , $ timeToLive ) ; $ options -> setLocationMode ( LocationMode :: PRIMARY_ONLY ) ; $ dataSerializer = $ this -> dataSerializer ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_CREATED , $ body , $ options ) -> then ( function ( $ response ) use ( $ dataSerializer ) { $ parsed = $ dataSerializer -> unserialize ( $ response -> getBody ( ) ) ; return CreateMessageResult :: create ( $ parsed ) ; } , null ) ; }

Creates promise to add a message to the queue and optionally sets a
visibility timeout for the message.

@param string               $queueName   The name of the queue.
@param string               $messageText The message contents.
@param CreateMessageOptions $options     The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

Creates promise to add a message to the queue and optionally sets a visibility timeout for the message .


public function createQueue(
        $queueName,
        Models\CreateQueueOptions $options = null
    ) {
        $this->createQueueAsync($queueName, $options)->wait();
    }

public function createQueue ( $ queueName , Models \ CreateQueueOptions $ options = null ) { $ this -> createQueueAsync ( $ queueName , $ options ) -> wait ( ) ; }

Creates a new queue under the storage account.

@param string                    $queueName The queue name.
@param Models\CreateQueueOptions  $options   The Optional parameters.

@return void

Creates a new queue under the storage account .


public function createQueueAsync(
        $queueName,
        Models\CreateQueueOptions $options = null
    ) {
        Validate::canCastAsString($queueName, 'queueName');
        Validate::notNullOrEmpty($queueName, 'queueName');

        $method      = Resources::HTTP_PUT;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $queueName;

        if (is_null($options)) {
            $options = new CreateQueueOptions();
        }

        $metadata = $options->getMetadata();
        $headers  = $this->generateMetadataHeaders($metadata);

        $options->setLocationMode(LocationMode::PRIMARY_ONLY);

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            array(Resources::STATUS_CREATED, Resources::STATUS_NO_CONTENT),
            Resources::EMPTY_STRING,
            $options
        );
    }

public function createQueueAsync ( $ queueName , Models \ CreateQueueOptions $ options = null ) { Validate :: canCastAsString ( $ queueName , 'queueName' ) ; Validate :: notNullOrEmpty ( $ queueName , 'queueName' ) ; $ method = Resources :: HTTP_PUT ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ queueName ; if ( is_null ( $ options ) ) { $ options = new CreateQueueOptions ( ) ; } $ metadata = $ options -> getMetadata ( ) ; $ headers = $ this -> generateMetadataHeaders ( $ metadata ) ; $ options -> setLocationMode ( LocationMode :: PRIMARY_ONLY ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , array ( Resources :: STATUS_CREATED , Resources :: STATUS_NO_CONTENT ) , Resources :: EMPTY_STRING , $ options ) ; }

Creates promise to create a new queue under the storage account.

@param string                     $queueName The queue name.
@param Models\CreateQueueOptions  $options   The Optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

Creates promise to create a new queue under the storage account .


public function deleteMessage(
        $queueName,
        $messageId,
        $popReceipt,
        QueueServiceOptions $options = null
    ) {
        $this->deleteMessageAsync(
            $queueName,
            $messageId,
            $popReceipt,
            $options
        )->wait();
    }

public function deleteMessage ( $ queueName , $ messageId , $ popReceipt , QueueServiceOptions $ options = null ) { $ this -> deleteMessageAsync ( $ queueName , $ messageId , $ popReceipt , $ options ) -> wait ( ) ; }

Deletes a specified message from the queue.

@param string              $queueName  The name of the queue.
@param string              $messageId  The id of the message.
@param string              $popReceipt The valid pop receipt value returned
from an earlier call to the Get Messages or Update Message operation.
@param QueueServiceOptions $options    The optional parameters.

@return void

Deletes a specified message from the queue .


public function deleteMessageAsync(
        $queueName,
        $messageId,
        $popReceipt,
        QueueServiceOptions $options = null
    ) {
        Validate::canCastAsString($queueName, 'queueName');
        Validate::notNullOrEmpty($queueName, 'queueName');
        Validate::canCastAsString($messageId, 'messageId');
        Validate::notNullOrEmpty($messageId, 'messageId');
        Validate::canCastAsString($popReceipt, 'popReceipt');
        Validate::notNullOrEmpty($popReceipt, 'popReceipt');

        $method      = Resources::HTTP_DELETE;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $queueName . '/messages/' . $messageId;
        $body        = Resources::EMPTY_STRING;

        if (is_null($options)) {
            $options = new QueueServiceOptions();
        }

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_POPRECEIPT,
            $popReceipt
        );

        $options->setLocationMode(LocationMode::PRIMARY_ONLY);

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_NO_CONTENT,
            $body,
            $options
        );
    }

public function deleteMessageAsync ( $ queueName , $ messageId , $ popReceipt , QueueServiceOptions $ options = null ) { Validate :: canCastAsString ( $ queueName , 'queueName' ) ; Validate :: notNullOrEmpty ( $ queueName , 'queueName' ) ; Validate :: canCastAsString ( $ messageId , 'messageId' ) ; Validate :: notNullOrEmpty ( $ messageId , 'messageId' ) ; Validate :: canCastAsString ( $ popReceipt , 'popReceipt' ) ; Validate :: notNullOrEmpty ( $ popReceipt , 'popReceipt' ) ; $ method = Resources :: HTTP_DELETE ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ queueName . '/messages/' . $ messageId ; $ body = Resources :: EMPTY_STRING ; if ( is_null ( $ options ) ) { $ options = new QueueServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_POPRECEIPT , $ popReceipt ) ; $ options -> setLocationMode ( LocationMode :: PRIMARY_ONLY ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_NO_CONTENT , $ body , $ options ) ; }

Creates promise to delete a specified message from the queue.

@param string              $queueName  The name of the queue.
@param string              $messageId  The id of the message.
@param string              $popReceipt The valid pop receipt value returned
from an earlier call to the Get Messages or Update Message operation.
@param QueueServiceOptions $options    The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

Creates promise to delete a specified message from the queue .


public function deleteQueue($queueName, QueueServiceOptions $options = null)
    {
        $this->deleteQueueAsync($queueName, $options)->wait();
    }

public function deleteQueue ( $ queueName , QueueServiceOptions $ options = null ) { $ this -> deleteQueueAsync ( $ queueName , $ options ) -> wait ( ) ; }

Deletes a queue.

@param string              $queueName The queue name.
@param QueueServiceOptions $options   The optional parameters.

@return void


public function deleteQueueAsync(
        $queueName,
        QueueServiceOptions $options = null
    ) {
        Validate::canCastAsString($queueName, 'queueName');
        Validate::notNullOrEmpty($queueName, 'queueName');

        $method      = Resources::HTTP_DELETE;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $queueName;

        if (is_null($options)) {
            $options = new QueueServiceOptions();
        }

        $options->setLocationMode(LocationMode::PRIMARY_ONLY);

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_NO_CONTENT,
            Resources::EMPTY_STRING,
            $options
        );
    }

public function deleteQueueAsync ( $ queueName , QueueServiceOptions $ options = null ) { Validate :: canCastAsString ( $ queueName , 'queueName' ) ; Validate :: notNullOrEmpty ( $ queueName , 'queueName' ) ; $ method = Resources :: HTTP_DELETE ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ queueName ; if ( is_null ( $ options ) ) { $ options = new QueueServiceOptions ( ) ; } $ options -> setLocationMode ( LocationMode :: PRIMARY_ONLY ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_NO_CONTENT , Resources :: EMPTY_STRING , $ options ) ; }

Creates promise to delete a queue.

@param string              $queueName The queue name.
@param QueueServiceOptions $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface


public function getQueueMetadata($queueName, QueueServiceOptions $options = null)
    {
        return $this->getQueueMetadataAsync($queueName, $options)->wait();
    }

public function getQueueMetadata ( $ queueName , QueueServiceOptions $ options = null ) { return $ this -> getQueueMetadataAsync ( $ queueName , $ options ) -> wait ( ) ; }

Returns queue properties, including user-defined metadata.

@param string              $queueName The queue name.
@param QueueServiceOptions $options   The optional parameters.

@return Models\GetQueueMetadataResult

Returns queue properties including user - defined metadata .


public function getQueueMetadataAsync(
        $queueName,
        QueueServiceOptions $options = null
    ) {
        Validate::canCastAsString($queueName, 'queueName');
        Validate::notNullOrEmpty($queueName, 'queueName');

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $queueName;
        $body        = Resources::EMPTY_STRING;

        if (is_null($options)) {
            $options = new QueueServiceOptions();
        }

        $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'metadata');

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            $body,
            $options
        )->then(function ($response) {
            $responseHeaders = HttpFormatter::formatHeaders($response->getHeaders());
            $metadata = Utilities::getMetadataArray($responseHeaders);
            $maxCount = intval(
                Utilities::tryGetValue(
                    $responseHeaders,
                    Resources::X_MS_APPROXIMATE_MESSAGES_COUNT
                )
            );

            return new GetQueueMetadataResult($maxCount, $metadata);
        }, null);
    }

public function getQueueMetadataAsync ( $ queueName , QueueServiceOptions $ options = null ) { Validate :: canCastAsString ( $ queueName , 'queueName' ) ; Validate :: notNullOrEmpty ( $ queueName , 'queueName' ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ queueName ; $ body = Resources :: EMPTY_STRING ; if ( is_null ( $ options ) ) { $ options = new QueueServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , 'metadata' ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , $ body , $ options ) -> then ( function ( $ response ) { $ responseHeaders = HttpFormatter :: formatHeaders ( $ response -> getHeaders ( ) ) ; $ metadata = Utilities :: getMetadataArray ( $ responseHeaders ) ; $ maxCount = intval ( Utilities :: tryGetValue ( $ responseHeaders , Resources :: X_MS_APPROXIMATE_MESSAGES_COUNT ) ) ; return new GetQueueMetadataResult ( $ maxCount , $ metadata ) ; } , null ) ; }

Creates promise to return queue properties, including user-defined metadata.

@param string              $queueName The queue name.
@param QueueServiceOptions $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

Creates promise to return queue properties including user - defined metadata .


public function listMessages($queueName, ListMessagesOptions $options = null)
    {
        return $this->listMessagesAsync($queueName, $options)->wait();
    }

public function listMessages ( $ queueName , ListMessagesOptions $ options = null ) { return $ this -> listMessagesAsync ( $ queueName , $ options ) -> wait ( ) ; }

Lists all messages in the queue.

@param string              $queueName The queue name.
@param ListMessagesOptions $options   The optional parameters.

@return Models\ListMessagesResult


public function listMessagesAsync(
        $queueName,
        ListMessagesOptions $options = null
    ) {
        Validate::canCastAsString($queueName, 'queueName');
        Validate::notNullOrEmpty($queueName, 'queueName');

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $queryParams = array();
        $postParams  = array();
        $path        = $queueName . '/messages';

        if (is_null($options)) {
            $options = new ListMessagesOptions();
        }

        $messagesCount = $options->getNumberOfMessages();
        $visibility    = $options->getVisibilityTimeoutInSeconds();

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_NUM_OF_MESSAGES,
            $messagesCount
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_VISIBILITY_TIMEOUT,
            $visibility
        );

        $dataSerializer = $this->dataSerializer;

        $options->setLocationMode(LocationMode::PRIMARY_ONLY);

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) use ($dataSerializer) {
            $parsed = $dataSerializer->unserialize($response->getBody());
            return ListMessagesResult::create($parsed);
        }, null);
    }

public function listMessagesAsync ( $ queueName , ListMessagesOptions $ options = null ) { Validate :: canCastAsString ( $ queueName , 'queueName' ) ; Validate :: notNullOrEmpty ( $ queueName , 'queueName' ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ queryParams = array ( ) ; $ postParams = array ( ) ; $ path = $ queueName . '/messages' ; if ( is_null ( $ options ) ) { $ options = new ListMessagesOptions ( ) ; } $ messagesCount = $ options -> getNumberOfMessages ( ) ; $ visibility = $ options -> getVisibilityTimeoutInSeconds ( ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_NUM_OF_MESSAGES , $ messagesCount ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_VISIBILITY_TIMEOUT , $ visibility ) ; $ dataSerializer = $ this -> dataSerializer ; $ options -> setLocationMode ( LocationMode :: PRIMARY_ONLY ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) use ( $ dataSerializer ) { $ parsed = $ dataSerializer -> unserialize ( $ response -> getBody ( ) ) ; return ListMessagesResult :: create ( $ parsed ) ; } , null ) ; }

Creates promise to list all messages in the queue.

@param string              $queueName The queue name.
@param ListMessagesOptions $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

Creates promise to list all messages in the queue .


public function peekMessages($queueName, PeekMessagesOptions $options = null)
    {
        return $this->peekMessagesAsync($queueName, $options)->wait();
    }

public function peekMessages ( $ queueName , PeekMessagesOptions $ options = null ) { return $ this -> peekMessagesAsync ( $ queueName , $ options ) -> wait ( ) ; }

Retrieves a message from the front of the queue, without changing
the message visibility.

@param string              $queueName The queue name.
@param PeekMessagesOptions $options   The optional parameters.

@return Models\PeekMessagesResult

Retrieves a message from the front of the queue without changing the message visibility .


public function peekMessagesAsync(
        $queueName,
        PeekMessagesOptions $options = null
    ) {
        Validate::canCastAsString($queueName, 'queueName');
        Validate::notNullOrEmpty($queueName, 'queueName');

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $queryParams = array();
        $postParams  = array();
        $path        = $queueName . '/messages';

        if (is_null($options)) {
            $options = new PeekMessagesOptions();
        }

        $messagesCount = $options->getNumberOfMessages();

        $this->addOptionalQueryParam($queryParams, Resources::QP_PEEK_ONLY, 'true');
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_NUM_OF_MESSAGES,
            $messagesCount
        );

        $dataSerializer = $this->dataSerializer;

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) use ($dataSerializer) {
            $parsed = $dataSerializer->unserialize($response->getBody());
            return PeekMessagesResult::create($parsed);
        }, null);
    }

public function peekMessagesAsync ( $ queueName , PeekMessagesOptions $ options = null ) { Validate :: canCastAsString ( $ queueName , 'queueName' ) ; Validate :: notNullOrEmpty ( $ queueName , 'queueName' ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ queryParams = array ( ) ; $ postParams = array ( ) ; $ path = $ queueName . '/messages' ; if ( is_null ( $ options ) ) { $ options = new PeekMessagesOptions ( ) ; } $ messagesCount = $ options -> getNumberOfMessages ( ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_PEEK_ONLY , 'true' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_NUM_OF_MESSAGES , $ messagesCount ) ; $ dataSerializer = $ this -> dataSerializer ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) use ( $ dataSerializer ) { $ parsed = $ dataSerializer -> unserialize ( $ response -> getBody ( ) ) ; return PeekMessagesResult :: create ( $ parsed ) ; } , null ) ; }

Creates promise to retrieve a message from the front of the queue,
without changing the message visibility.

@param string              $queueName The queue name.
@param PeekMessagesOptions $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

Creates promise to retrieve a message from the front of the queue without changing the message visibility .


public function generateAccountSharedAccessSignatureToken(
        $signedVersion,
        $signedPermissions,
        $signedService,
        $signedResourceType,
        $signedExpiry,
        $signedStart = "",
        $signedIP = "",
        $signedProtocol = ""
    ) {
        // check that version is valid
        Validate::canCastAsString($signedVersion, 'signedVersion');
        Validate::notNullOrEmpty($signedVersion, 'signedVersion');
        Validate::isDateString($signedVersion, 'signedVersion');

        // validate and sanitize signed service
        $signedService = $this->validateAndSanitizeSignedService($signedService);

        // validate and sanitize signed resource type
        $signedResourceType = $this->validateAndSanitizeSignedResourceType($signedResourceType);

        // validate and sanitize signed permissions
        $signedPermissions = $this->validateAndSanitizeSignedPermissions($signedPermissions);

        // check that expiracy is valid
        if ($signedExpiry instanceof \Datetime) {
            $signedExpiry = Utilities::isoDate($signedExpiry);
        }
        Validate::canCastAsString($signedExpiry, 'signedExpiry');
        Validate::notNullOrEmpty($signedExpiry, 'signedExpiry');
        Validate::isDateString($signedExpiry, 'signedExpiry');

        // check that signed start is valid
        if ($signedStart instanceof \Datetime) {
            $signedStart = Utilities::isoDate($signedStart);
        }
        Validate::canCastAsString($signedStart, 'signedStart');
        if (strlen($signedStart) > 0) {
            Validate::isDateString($signedStart, 'signedStart');
        }

        // check that signed IP is valid
        Validate::canCastAsString($signedIP, 'signedIP');

        // validate and sanitize signed protocol
        $signedProtocol = $this->validateAndSanitizeSignedProtocol($signedProtocol);

        // construct an array with the parameters to generate the shared access signature at the account level
        $parameters = array();
        $parameters[] = $this->accountName;
        $parameters[] = $signedPermissions;
        $parameters[] = $signedService;
        $parameters[] = $signedResourceType;
        $parameters[] = $signedStart;
        $parameters[] = $signedExpiry;
        $parameters[] = $signedIP;
        $parameters[] = $signedProtocol;
        $parameters[] = $signedVersion;

        // implode the parameters into a string
        $stringToSign = utf8_encode(implode("\n", $parameters) . "\n");

        // decode the account key from base64
        $decodedAccountKey = base64_decode($this->accountKey);

        // create the signature with hmac sha256
        $signature = hash_hmac("sha256", $stringToSign, $decodedAccountKey, true);

        // encode the signature as base64 and url encode.
        $sig = urlencode(base64_encode($signature));

        //adding all the components for account SAS together.
        $sas  = 'sv=' . $signedVersion;
        $sas .= '&ss=' . $signedService;
        $sas .= '&srt=' . $signedResourceType;
        $sas .= '&sp=' . $signedPermissions;
        $sas .= '&se=' . $signedExpiry;
        $sas .= $signedStart === ''? '' : '&st=' . $signedStart;
        $sas .= $signedIP === ''? '' : '&sip=' . $signedIP;
        $sas .= '&spr=' . $signedProtocol;
        $sas .= '&sig=' . $sig;

        // return the signature
        return $sas;
    }

Generates a shared access signature at the account level.

@param string $signedVersion           Specifies the signed version to use.
@param string $signedPermissions       Specifies the signed permissions for
the account SAS.
@param string $signedService           Specifies the signed services
accessible with the account SAS.
@param string $signedResourceType      Specifies the signed resource types
that are accessible with the account
SAS.
@param \Datetime|string $signedExpiry  The time at which the shared access
signature becomes invalid, in an ISO
8601 format.
@param \Datetime|string $signedStart   The time at which the SAS becomes
valid, in an ISO 8601 format.
@param string $signedIP                Specifies an IP address or a range
of IP addresses from which to accept
requests.
@param string $signedProtocol          Specifies the protocol permitted for
a request made with the account SAS.

@see Constructing an account SAS at
https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/constructing-an-account-sas

@return string

Generates a shared access signature at the account level .


protected function validateAndSanitizeSignedService($signedService)
    {
        // validate signed service is not null or empty
        Validate::canCastAsString($signedService, 'signedService');
        Validate::notNullOrEmpty($signedService, 'signedService');

        // The signed service should only be a combination of the letters b(lob) q(ueue) t(able) or f(ile)
        $validServices = ['b', 'q', 't', 'f'];

        return $this->validateAndSanitizeStringWithArray(
            strtolower($signedService),
            $validServices
        );
    }

Validates and sanitizes the signed service parameter

@param string $signedService Specifies the signed services accessible
with the account SAS.

@return string


protected function validateAndSanitizeSignedResourceType($signedResourceType)
    {
        // validate signed resource type is not null or empty
        Validate::canCastAsString($signedResourceType, 'signedResourceType');
        Validate::notNullOrEmpty($signedResourceType, 'signedResourceType');

        // The signed resource type should only be a combination of the letters s(ervice) c(container) or o(bject)
        $validResourceTypes = ['s', 'c', 'o'];

        return $this->validateAndSanitizeStringWithArray(
            strtolower($signedResourceType),
            $validResourceTypes
        );
    }

Validates and sanitizes the signed resource type parameter

@param string $signedResourceType    Specifies the signed resource types
that are accessible with the account
SAS.

@return string


protected function validateAndSanitizeSignedPermissions(
        $signedPermissions
    ) {
        // validate signed permissions are not null or empty
        Validate::canCastAsString($signedPermissions, 'signedPermissions');
        Validate::notNullOrEmpty($signedPermissions, 'signedPermissions');

        $validPermissions = ['r', 'w', 'd', 'l', 'a', 'c', 'u', 'p'];

        return $this->validateAndSanitizeStringWithArray(
            strtolower($signedPermissions),
            $validPermissions
        );
    }

Validates and sanitizes the signed permissions parameter

@param string $signedPermissions Specifies the signed permissions for the
account SAS.

@return string


protected function validateAndSanitizeSignedProtocol($signedProtocol)
    {
        Validate::canCastAsString($signedProtocol, 'signedProtocol');
        // sanitize string
        $sanitizedSignedProtocol = strtolower($signedProtocol);
        if (strlen($sanitizedSignedProtocol) > 0) {
            if (strcmp($sanitizedSignedProtocol, "https") != 0 && strcmp($sanitizedSignedProtocol, "https,http") != 0) {
                throw new \InvalidArgumentException(Resources::SIGNED_PROTOCOL_INVALID_VALIDATION_MSG);
            }
        }

        return $sanitizedSignedProtocol;
    }

protected
function
validateAndSanitizeSignedProtocol
(
$
signedProtocol
)
{
Validate
::
canCastAsString
(
$
signedProtocol
,
'signedProtocol'
)
;
// sanitize string
$
sanitizedSignedProtocol
=
strtolower
(
$
signedProtocol
)
;
if
(
strlen
(
$
sanitizedSignedProtocol
)
>
0
)
{
if
(
strcmp
(
$
sanitizedSignedProtocol
,
"https"
)
!=
0
&&
strcmp
(
$
sanitizedSignedProtocol
,
"https,http"
)
!=
0
)
{
throw
new
\
InvalidArgumentException
(
Resources
::
SIGNED_PROTOCOL_INVALID_VALIDATION_MSG
)
;
}
}
return
$
sanitizedSignedProtocol
;
}

Validates and sanitizes the signed protocol parameter

@param string $signedProtocol Specifies the signed protocol for the
account SAS.

@return string


protected function validateAndSanitizeStringWithArray($input, array $array)
    {
        $result = '';
        foreach ($array as $value) {
            if (strpos($input, $value) !== false) {
                //append the valid permission to result.
                $result .= $value;
                //remove all the character that represents the permission.
                $input = str_replace(
                    $value,
                    '',
                    $input
                );
            }
        }

        Validate::isTrue(
            strlen($input) == '',
            sprintf(
                Resources::STRING_NOT_WITH_GIVEN_COMBINATION,
                implode(', ', $array)
            )
        );
        return $result;
    }

Removes duplicate characters from a string

@param string $input        The input string.

@return string


protected static function generateCanonicalResource(
        $accountName,
        $service,
        $resource
    ) {
        static $serviceMap = array(
            Resources::RESOURCE_TYPE_BLOB  => 'blob',
            Resources::RESOURCE_TYPE_FILE  => 'file',
            Resources::RESOURCE_TYPE_QUEUE => 'queue',
            Resources::RESOURCE_TYPE_TABLE => 'table',
        );
        $serviceName = $serviceMap[$service];
        if (Utilities::startsWith($resource, '/')) {
            $resource = substr($resource, 1);
        }
        return sprintf('/%s/%s/%s', $serviceName, $accountName, $resource);
    }

protected static function generateCanonicalResource ( $ accountName , $ service , $ resource ) { static $ serviceMap = array ( Resources :: RESOURCE_TYPE_BLOB => 'blob' , Resources :: RESOURCE_TYPE_FILE => 'file' , Resources :: RESOURCE_TYPE_QUEUE => 'queue' , Resources :: RESOURCE_TYPE_TABLE => 'table' , ) ; $ serviceName = $ serviceMap [ $ service ] ; if ( Utilities :: startsWith ( $ resource , '/' ) ) { $ resource = substr ( $ resource , 1 ) ; } return sprintf ( '/%s/%s/%s' , $ serviceName , $ accountName , $ resource ) ; }

Generate the canonical resource using the given account name, service
type and resource.

@param  string $accountName The account name of the service.
@param  string $service     The service name of the service.
@param  string $resource    The name of the resource.

@return string

Generate the canonical resource using the given account name service type and resource .


protected static function parseErrorMessage(ResponseInterface $response)
    {
        //try to parse using xml serializer, if failed, return the whole body
        //as the error message.
        $serializer = new XmlSerializer();
        $errorMessage = '';
        try {
            $internalErrors = libxml_use_internal_errors(true);
            $parsedArray = $serializer->unserialize($response->getBody());
            $messages = array();
            foreach (libxml_get_errors() as $error) {
                $messages[] = $error->message;
            }
            if (!empty($messages)) {
                throw new \Exception(
                    sprintf(Resources::ERROR_CANNOT_PARSE_XML, implode('; ', $messages))
                );
            }
            libxml_use_internal_errors($internalErrors);
            if (array_key_exists(Resources::XTAG_MESSAGE, $parsedArray)) {
                $errorMessage = $parsedArray[Resources::XTAG_MESSAGE];
            } else {
                $errorMessage = $response->getBody();
            }
        } catch (\Exception $e) {
            $errorMessage = $response->getBody();
        }
        return $errorMessage;
    }

Error message to be parsed.

@param  ResponseInterface $response The response with a response body.

@internal

@return string