public function getRequestID()
    {
        $requestID = '';
        if (array_key_exists(
            Resources::X_MS_REQUEST_ID,
            $this->getResponse()->getHeaders()
        )) {
            $requestID = $this->getResponse()
                ->getHeaders()[Resources::X_MS_REQUEST_ID][0];
        }
        return $requestID;
    }

public function getRequestID ( ) { $ requestID = '' ; if ( array_key_exists ( Resources :: X_MS_REQUEST_ID , $ this -> getResponse ( ) -> getHeaders ( ) ) ) { $ requestID = $ this -> getResponse ( ) -> getHeaders ( ) [ Resources :: X_MS_REQUEST_ID ] [ 0 ] ; } return $ requestID ; }

Gets the request ID of the failure.

@return string


public function getDate()
    {
        $date = '';
        if (array_key_exists(
            Resources::DATE,
            $this->getResponse()->getHeaders()
        )) {
            $date = $this->getResponse()
                ->getHeaders()[Resources::DATE][0];
        }
        return $date;
    }

public function getDate ( ) { $ date = '' ; if ( array_key_exists ( Resources :: DATE , $ this -> getResponse ( ) -> getHeaders ( ) ) ) { $ date = $ this -> getResponse ( ) -> getHeaders ( ) [ Resources :: DATE ] [ 0 ] ; } return $ date ; }

Gets the Date of the failure.

@return string


public function setMiddlewares(array $middlewares)
    {
        foreach ($middlewares as $middleware) {
            self::validateIsMiddleware($middleware);
        }
        $this->middlewares = $middlewares;
    }

public function setMiddlewares ( array $ middlewares ) { foreach ( $ middlewares as $ middleware ) { self :: validateIsMiddleware ( $ middleware ) ; } $ this -> middlewares = $ middlewares ; }

Sets middlewares.

@param array $middlewares value.

@return void


private static function validateIsMiddleware($middleware)
    {
        if (!(is_callable($middleware) || $middleware instanceof IMiddleware)) {
            Validate::isTrue(
                false,
                Resources::INVALID_TYPE_MSG . 'callable or IMiddleware'
            );
        }
    }

private
static
function
validateIsMiddleware
(
$
middleware
)
{
if
(
!
(
is_callable
(
$
middleware
)
||
$
middleware
instanceof
IMiddleware
)
)
{
Validate
::
isTrue
(
false
,
Resources
::
INVALID_TYPE_MSG
.
'callable or IMiddleware'
)
;
}
}

Validate if the given middleware is of callable or IMiddleware.

@param  void $middleware the middleware to be validated.

@return void

Validate if the given middleware is of callable or IMiddleware .


private function _parse()
    {
        $key                    = null;
        $value                  = null;
        $connectionStringValues = array();

        while (true) {
            $this->_skipWhiteSpaces();

            if ($this->_pos == strlen($this->_value)
                && $this->_state != ConnectionStringParser::EXPECT_VALUE
            ) {
                // Not stopping after the end has been reached and a value is
                // expected results in creating an empty value, which we expect.
                break;
            }

            switch ($this->_state) {
                case ConnectionStringParser::EXPECT_KEY:
                    $key          = $this->_extractKey();
                    $this->_state = ConnectionStringParser::EXPECT_ASSIGNMENT;
                    break;

                case ConnectionStringParser::EXPECT_ASSIGNMENT:
                    $this->_skipOperator('=');
                    $this->_state = ConnectionStringParser::EXPECT_VALUE;
                    break;

                case ConnectionStringParser::EXPECT_VALUE:
                    $value                        = $this->_extractValue();
                    $this->_state                 =
                    ConnectionStringParser::EXPECT_SEPARATOR;
                    $connectionStringValues[$key] = $value;
                    $key                          = null;
                    $value                        = null;
                    break;

                default:
                    $this->_skipOperator(';');
                    $this->_state = ConnectionStringParser::EXPECT_KEY;
                    break;
            }
        }

        // Must end parsing in the valid state (expected key or separator)
        if ($this->_state == ConnectionStringParser::EXPECT_ASSIGNMENT) {
            throw $this->_createException(
                $this->_pos,
                Resources::MISSING_CONNECTION_STRING_CHAR,
                '='
            );
        }

        return $connectionStringValues;
    }

Parses the connection string.

@return array

@throws \RuntimeException


private function _createException($position, $errorString)
    {
        $arguments = func_get_args();

        // Remove first and second arguments (position and error string)
        unset($arguments[0], $arguments[1]);

        // Create a short error message.
        $errorString = vsprintf($errorString, $arguments);

        // Add position.
        $errorString = sprintf(
            Resources::ERROR_PARSING_STRING,
            $errorString,
            $position
        );

        // Create final error message.
        $errorString = sprintf(
            Resources::INVALID_CONNECTION_STRING,
            $this->_argumentName,
            $errorString
        );

        return new \RuntimeException($errorString);
    }

Generates an invalid connection string exception with the detailed error
message.

@param integer $position    The position of the error.
@param string  $errorString The short error formatting string.

@return \RuntimeException

Generates an invalid connection string exception with the detailed error message .


private function _extractKey()
    {
        $key      = null;
        $firstPos = $this->_pos;
        $ch       = $this->_value[$this->_pos];

        if ($ch == '"' || $ch == '\'') {
            $this->_pos++;
            $key = $this->_extractString($ch);
        } elseif ($ch == ';' || $ch == '=') {
            // Key name was expected.
            throw $this->_createException(
                $firstPos,
                Resources::ERROR_CONNECTION_STRING_MISSING_KEY
            );
        } else {
            while ($this->_pos < strlen($this->_value)) {
                $ch = $this->_value[$this->_pos];

                // At this point we've read the key, break.
                if ($ch == '=') {
                    break;
                }

                $this->_pos++;
            }
            $key = rtrim(substr($this->_value, $firstPos, $this->_pos - $firstPos));
        }

        if (strlen($key) == 0) {
            // Empty key name.
            throw $this->_createException(
                $firstPos,
                Resources::ERROR_CONNECTION_STRING_EMPTY_KEY
            );
        }

        return $key;
    }

Extracts key at the current position.

@return string


private function _extractString($quote)
    {
        $firstPos = $this->_pos;

        while ($this->_pos < strlen($this->_value)
              &&  $this->_value[$this->_pos] != $quote
        ) {
            $this->_pos++;
        }

        if ($this->_pos == strlen($this->_value)) {
            // Runaway string.
            throw $this->_createException(
                $this->_pos,
                Resources::ERROR_CONNECTION_STRING_MISSING_CHARACTER,
                $quote
            );
        }

        return substr($this->_value, $firstPos, $this->_pos++ - $firstPos);
    }

Extracts the string until the given quotation mark.

@param string $quote The quotation mark terminating the string.

@return string

Extracts the string until the given quotation mark .


private function _skipOperator($operatorChar)
    {
        if ($this->_value[$this->_pos] != $operatorChar) {
            // Character was expected.
            throw $this->_createException(
                $this->_pos,
                Resources::MISSING_CONNECTION_STRING_CHAR,
                $operatorChar
            );
        }

        $this->_pos++;
    }

private
function
_skipOperator
(
$
operatorChar
)
{
if
(
$
this
->
_value
[
$
this
->
_pos
]
!=
$
operatorChar
)
{
// Character was expected.
throw
$
this
->
_createException
(
$
this
->
_pos
,
Resources
::
MISSING_CONNECTION_STRING_CHAR
,
$
operatorChar
)
;
}
$
this
->
_pos
++
;
}

Skips specified operator.

@param string $operatorChar The operator character.

@return void

@throws \RuntimeException


public static function create(
        $etag,
        \DateTime $lastModified,
        array $parsed = null
    ) {
        $result = new GetShareAclResult();
        $result->setETag($etag);
        $result->setLastModified($lastModified);
        $acl = ShareACL::create($parsed);
        $result->setShareAcl($acl);

        return $result;
    }

public static function create ( $ etag , \ DateTime $ lastModified , array $ parsed = null ) { $ result = new GetShareAclResult ( ) ; $ result -> setETag ( $ etag ) ; $ result -> setLastModified ( $ lastModified ) ; $ acl = ShareACL :: create ( $ parsed ) ; $ result -> setShareAcl ( $ acl ) ; return $ result ; }

Parses the given array into signed identifiers

@param string    $etag         share etag
@param \DateTime $lastModified last modification date
@param array     $parsed       parsed response into array
representation

@internal

@return self


protected function onRequest(RequestInterface $request)
    {
        $result = $request;

        //Adding headers.
        foreach ($this->headers as $key => $value) {
            $headers = $result->getHeaders();
            if (!array_key_exists($key, $headers)) {
                $result = $result->withHeader($key, $value);
            }
        }

        //rewriting version and user-agent.
        $result = $result->withHeader(
            Resources::X_MS_VERSION,
            $this->msVersion
        );
        $result = $result->withHeader(
            Resources::USER_AGENT,
            $this->userAgent
        );

        //Adding date.
        $date = gmdate(Resources::AZURE_DATE_FORMAT, time());
        $result = $result->withHeader(Resources::DATE, $date);

        //Adding request-ID if not specified by the user.
        if (!$result->hasHeader(Resources::X_MS_REQUEST_ID)) {
            $result = $result->withHeader(Resources::X_MS_REQUEST_ID, \uniqid());
        }
        //Sign the request if authentication scheme is not null.
        $request = $this->authenticationScheme == null ?
            $request : $this->authenticationScheme->signRequest($result);
        return $request;
    }

Add the provided headers, the date, then sign the request using the
authentication scheme, and return it.

@param  RequestInterface $request un-signed request.

@return RequestInterface

Add the provided headers the date then sign the request using the authentication scheme and return it .


protected static function settingWithFunc($name, $predicate)
    {
        $requirement                                = array();
        $requirement[Resources::SETTING_NAME]       = $name;
        $requirement[Resources::SETTING_CONSTRAINT] = $predicate;

        return $requirement;
    }

protected static function settingWithFunc ( $ name , $ predicate ) { $ requirement = array ( ) ; $ requirement [ Resources :: SETTING_NAME ] = $ name ; $ requirement [ Resources :: SETTING_CONSTRAINT ] = $ predicate ; return $ requirement ; }

Creates a setting value condition using the passed predicate.

@param string   $name      The setting key name.
@param callable $predicate The setting value predicate.

@return array

Creates a setting value condition using the passed predicate .


protected static function setting($name)
    {
        $validValues = func_get_args();

        // Remove $name argument.
        unset($validValues[0]);

        $validValuesCount = func_num_args();

        $predicate = function ($settingValue) use ($validValuesCount, $validValues) {
            if (empty($validValues)) {
                // No restrictions, succeed,
                return true;
            }

            // Check to find if the $settingValue is valid or not. The index must
            // start from 1 as unset deletes the value but does not update the array
            // indecies.
            for ($index = 1; $index < $validValuesCount; $index++) {
                if ($settingValue == $validValues[$index]) {
                    // $settingValue is found in valid values set, succeed.
                    return true;
                }
            }

            throw new \RuntimeException(
                sprintf(
                    Resources::INVALID_CONFIG_VALUE,
                    $settingValue,
                    implode("\n", $validValues)
                )
            );

            // $settingValue is missing in valid values set, fail.
            return false;
        };

        return self::settingWithFunc($name, $predicate);
    }

Creates a setting value condition that validates it is one of the
passed valid values.

@param string $name The setting key name.

@return array

Creates a setting value condition that validates it is one of the passed valid values .


protected static function matchedSpecification(array $settings)
    {
        $constraints = func_get_args();

        // Remove first element which corresponds to $settings
        unset($constraints[0]);

        foreach ($constraints as $constraint) {
            $remainingSettings = $constraint($settings);

            if (is_null($remainingSettings)) {
                return false;
            } else {
                $settings = $remainingSettings;
            }
        }

        if (empty($settings)) {
            return true;
        }

        return false;
    }

Tests to see if a given list of settings matches a set of filters exactly.

@param array $settings The settings to check.

@return boolean If any filter returns null, false. If there are any settings
left over after all filters are processed, false. Otherwise true.

Tests to see if a given list of settings matches a set of filters exactly .


public function setNextRowKey($nextRowKey)
    {
        if ($this->continuationToken == null) {
            $this->setContinuationToken(new TableContinuationToken());
        }
        $this->continuationToken->setNextRowKey($nextRowKey);
    }

public function setNextRowKey ( $ nextRowKey ) { if ( $ this -> continuationToken == null ) { $ this -> setContinuationToken ( new TableContinuationToken ( ) ) ; } $ this -> continuationToken -> setNextRowKey ( $ nextRowKey ) ; }

Sets entity next row key.

@param string $nextRowKey The entity next row key value.

@return void


public function setNextPartitionKey($nextPartitionKey)
    {
        if ($this->continuationToken == null) {
            $this->setContinuationToken(new TableContinuationToken());
        }
        $this->continuationToken->setNextPartitionKey($nextPartitionKey);
    }

public function setNextPartitionKey ( $ nextPartitionKey ) { if ( $ this -> continuationToken == null ) { $ this -> setContinuationToken ( new TableContinuationToken ( ) ) ; } $ this -> continuationToken -> setNextPartitionKey ( $ nextPartitionKey ) ; }

Sets entity next partition key.

@param string $nextPartitionKey The entity next partition key value.

@return void


public static function processType($type)
    {
        $type = empty($type) ? self::STRING : $type;
        Validate::isTrue(self::isValid($type), Resources::INVALID_EDM_MSG);

        return $type;
    }

public static function processType ( $ type ) { $ type = empty ( $ type ) ? self :: STRING : $ type ; Validate :: isTrue ( self :: isValid ( $ type ) , Resources :: INVALID_EDM_MSG ) ; return $ type ; }

Converts the type to string if it's empty and validates the type.

@param string $type The Edm type

@internal

@return string

Converts the type to string if it s empty and validates the type .


public static function validateEdmValue($type, $value, &$condition = null)
    {
        // Having null value means that the user wants to remove the property name
        // associated with this value. Leave the value as null so this hold.
        if (is_null($value)) {
            return true;
        } else {
            switch ($type) {
            case EdmType::GUID:
            case EdmType::BINARY:
            case EdmType::STRING:
            case EdmType::INT64:
            case null:
                // NULL also is treated as EdmType::STRING
                $condition = 'is_string';
                return is_string($value);

            case EdmType::DOUBLE:
                $condition = 'is_double or is_string';
                return is_double($value) || is_int($value) || is_string($value);

            case EdmType::INT32:
                $condition = 'is_int or is_string';
                return is_int($value) || is_string($value);

            case EdmType::DATETIME:
                $condition = 'instanceof \DateTime';
                return $value instanceof \DateTime;

            case EdmType::BOOLEAN:
                $condition = 'is_bool';
                return is_bool($value);

            default:
                throw new \InvalidArgumentException();
            }
        }
    }

Validates that the value associated with the EDM type is valid.

@param string $type       The EDM type.
@param mixed  $value      The EDM value.
@param string &$condition The error message.

@internal

@return boolean

@throws \InvalidArgumentException

Validates that the value associated with the EDM type is valid .


public static function serializeValue($type, $value)
    {
        switch ($type) {
        case null:
            return $value;

        case EdmType::INT32:
            return intval($value);

        case EdmType::INT64:
        case EdmType::GUID:
        case EdmType::STRING:
            return strval($value);

        case EdmType::DOUBLE:
            return strval($value);

        case EdmType::BINARY:
            return base64_encode($value);

        case EdmType::DATETIME:
            return Utilities::convertToEdmDateTime($value);

        case EdmType::BOOLEAN:
            return (is_null($value) ? '' : ($value == true ? true : false));

        default:
            throw new \InvalidArgumentException();
        }
    }

public static function serializeValue ( $ type , $ value ) { switch ( $ type ) { case null : return $ value ; case EdmType :: INT32 : return intval ( $ value ) ; case EdmType :: INT64 : case EdmType :: GUID : case EdmType :: STRING : return strval ( $ value ) ; case EdmType :: DOUBLE : return strval ( $ value ) ; case EdmType :: BINARY : return base64_encode ( $ value ) ; case EdmType :: DATETIME : return Utilities :: convertToEdmDateTime ( $ value ) ; case EdmType :: BOOLEAN : return ( is_null ( $ value ) ? '' : ( $ value == true ? true : false ) ) ; default : throw new \ InvalidArgumentException ( ) ; } }

Serializes EDM value into proper value for sending it to Windows Azure.

@param string $type  The EDM type.
@param mixed  $value The EDM value.

@internal

@return string

@throws \InvalidArgumentException

Serializes EDM value into proper value for sending it to Windows Azure .


public static function serializeQueryValue($type, $value)
    {
        switch ($type) {
        case EdmType::DATETIME:
            $edmDate = Utilities::convertToEdmDateTime($value);
            return 'datetime\'' . $edmDate . '\'';

        case EdmType::BINARY:
            return 'X\'' . implode('', unpack("H*", $value)) . '\'';

        case EdmType::BOOLEAN:
            return ($value ? 'true' : 'false');

        case EdmType::DOUBLE:
        case EdmType::INT32:
            return $value;

        case EdmType::INT64:
            return $value . 'L';

        case EdmType::GUID:
            return 'guid\'' . $value . '\'';

        case null:
        case EdmType::STRING:
            // NULL also is treated as EdmType::STRING
            return '\'' . str_replace('\'', '\'\'', $value) . '\'';

        default:
            throw new \InvalidArgumentException();
        }
    }

Serializes EDM value into proper value to be used in query.

@param string $type  The EDM type.
@param mixed  $value The EDM value.

@internal

@return string

@throws \InvalidArgumentException

Serializes EDM value into proper value to be used in query .


public static function unserializeQueryValue($type, $value)
    {
        // Having null value means that the user wants to remove the property name
        // associated with this value. Leave the value as null so this hold.
        if (is_null($value)) {
            return null;
        } else {
            switch ($type) {
            case self::GUID:
            case self::STRING:
            case self::INT64:
            case null:
                return strval($value);

            case self::BINARY:
                return base64_decode($value);

            case self::DATETIME:
                return Utilities::convertToDateTime($value);

            case self::BOOLEAN:
                return Utilities::toBoolean($value);

            case self::DOUBLE:
                return doubleval($value);

            case self::INT32:
                return intval($value);

            default:
                throw new \InvalidArgumentException();
            }
        }
    }

Converts the value into its proper type.

@param string $type  The edm type.
@param string $value The edm value.

@internal

@return mixed

@throws \InvalidArgumentException

Converts the value into its proper type .


public static function create(array $parsedResponse)
    {
        $result = new ServiceProperties();

        if (array_key_exists(Resources::XTAG_DEFAULT_SERVICE_VERSION, $parsedResponse) &&
            $parsedResponse[Resources::XTAG_DEFAULT_SERVICE_VERSION] != null) {
            $result->setDefaultServiceVersion($parsedResponse[Resources::XTAG_DEFAULT_SERVICE_VERSION]);
        }

        if (array_key_exists(Resources::XTAG_LOGGING, $parsedResponse)) {
            $result->setLogging(Logging::create($parsedResponse[Resources::XTAG_LOGGING]));
        }
        $result->setHourMetrics(Metrics::create($parsedResponse[Resources::XTAG_HOUR_METRICS]));
        if (array_key_exists(Resources::XTAG_MINUTE_METRICS, $parsedResponse)) {
            $result->setMinuteMetrics(Metrics::create($parsedResponse[Resources::XTAG_MINUTE_METRICS]));
        }
        if (array_key_exists(Resources::XTAG_CORS, $parsedResponse) &&
            $parsedResponse[Resources::XTAG_CORS] != null) {
            //There could be multiple CORS rules, so need to extract them all.
            $corses = array();
            $corsArray =
                $parsedResponse[Resources::XTAG_CORS][Resources::XTAG_CORS_RULE];
            if (count(array_filter(array_keys($corsArray), 'is_string')) > 0) {
                //single cors rule
                $corses[] = CORS::create($corsArray);
            } else {
                //multiple cors rule
                foreach ($corsArray as $cors) {
                    $corses[] = CORS::create($cors);
                }
            }

            $result->setCorses($corses);
        } else {
            $result->setCorses(array());
        }

        return $result;
    }

Creates ServiceProperties object from parsed XML response.

@internal
@param array $parsedResponse XML response parsed into array.

@return ServiceProperties.

Creates ServiceProperties object from parsed XML response .


private function getCorsesArray()
    {
        $corsesArray = array();
        if (count($this->getCorses()) == 1) {
            $corsesArray = array(
                Resources::XTAG_CORS_RULE => $this->getCorses()[0]->toArray()
            );
        } elseif ($this->getCorses() != array()) {
            foreach ($this->getCorses() as $cors) {
                $corsesArray[] = [Resources::XTAG_CORS_RULE => $cors->toArray()];
            }
        }

        return $corsesArray;
    }

private function getCorsesArray ( ) { $ corsesArray = array ( ) ; if ( count ( $ this -> getCorses ( ) ) == 1 ) { $ corsesArray = array ( Resources :: XTAG_CORS_RULE => $ this -> getCorses ( ) [ 0 ] -> toArray ( ) ) ; } elseif ( $ this -> getCorses ( ) != array ( ) ) { foreach ( $ this -> getCorses ( ) as $ cors ) { $ corsesArray [ ] = [ Resources :: XTAG_CORS_RULE => $ cors -> toArray ( ) ] ; } } return $ corsesArray ; }

Gets the array that contains all the CORSes.

@return array

Gets the array that contains all the CORSes .


private static function _init()
    {
        if (!self::$_isInitialized) {
            self::$_defaultSources = array(
                self::ENVIRONMENT_SOURCE => array(__CLASS__, 'environmentSource')
            );
            self::$_isInitialized  = true;
        }
    }

private static function _init ( ) { if ( ! self :: $ _isInitialized ) { self :: $ _defaultSources = array ( self :: ENVIRONMENT_SOURCE => array ( __CLASS__ , 'environmentSource' ) ) ; self :: $ _isInitialized = true ; } }

Initializes the default sources.

@return void


public function parseTableEntries($body)
    {
        $tables     = array();
        $result     = json_decode($body, true);

        $rawEntries = $result[Resources::JSON_VALUE];

        foreach ($rawEntries as $entry) {
            $tables[] = $entry[Resources::JSON_TABLE_NAME];
        }

        return $tables;
    }

public function parseTableEntries ( $ body ) { $ tables = array ( ) ; $ result = json_decode ( $ body , true ) ; $ rawEntries = $ result [ Resources :: JSON_VALUE ] ; foreach ( $ rawEntries as $ entry ) { $ tables [ ] = $ entry [ Resources :: JSON_TABLE_NAME ] ; } return $ tables ; }

Constructs array of tables from HTTP response body.

@param string $body The HTTP response body.

@return array

Constructs array of tables from HTTP response body .


public function getEntity(Entity $entity)
    {
        $entityProperties = $entity->getProperties();
        $properties       = array();

        foreach ($entityProperties as $name => $property) {
            $edmType    = $property->getEdmType();
            $edmValue   = $property->getValue();

            if (is_null($edmValue)) {
                // No @odata.type JSON property needed for null value
                $properties[$name] = null;
            } else {
                if (is_null($edmType)) {
                    $edmType = EdmType::propertyType($edmValue);
                }

                $value             = EdmType::serializeValue($edmType, $edmValue);
                $properties[$name] = $value;

                if (EdmType::typeRequired($edmType)) {
                    $properties[$name . Resources::JSON_ODATA_TYPE_SUFFIX] = $edmType;
                }
            }
        }

        return json_encode($properties);
    }

Constructs JSON representation for entity.

@param Entity $entity The entity instance.

@return string

Constructs JSON representation for entity .


public function parseEntities($body)
    {
        $rawEntities = json_decode($body, true);
        $entities   = array();

        foreach ($rawEntities[Resources::JSON_VALUE] as $rawEntity) {
            $entities[] = $this->parseOneEntity($rawEntity);
        }

        return $entities;
    }

public function parseEntities ( $ body ) { $ rawEntities = json_decode ( $ body , true ) ; $ entities = array ( ) ; foreach ( $ rawEntities [ Resources :: JSON_VALUE ] as $ rawEntity ) { $ entities [ ] = $ this -> parseOneEntity ( $ rawEntity ) ; } return $ entities ; }

Constructs array of entities from HTTP response body.

@param string $body The HTTP response body.

@return array

Constructs array of entities from HTTP response body .


public function setStart(\DateTime $start = null)
    {
        if ($start != null) {
            Validate::isDate($start);
        }
        $this->start = $start;
    }

public function setStart ( \ DateTime $ start = null ) { if ( $ start != null ) { Validate :: isDate ( $ start ) ; } $ this -> start = $ start ; }

Sets start.

@param \DateTime $start value.

@return void


private function validatePermission($permission)
    {
        $validPermissions = static::getResourceValidPermissions();
        $result = '';
        foreach ($validPermissions as $validPermission) {
            if (strpos($permission, $validPermission) !== false) {
                //append the valid permission to result.
                $result .= $validPermission;
                //remove all the character that represents the permission.
                $permission = str_replace(
                    $validPermission,
                    '',
                    $permission
                );
            }
        }
        //After filtering all the permissions, if there is still characters
        //left in the given permission, throw exception.
        Validate::isTrue(
            $permission == '',
            sprintf(
                Resources::INVALID_PERMISSION_PROVIDED,
                $this->getResourceType(),
                implode(', ', $validPermissions)
            )
        );

        return $result;
    }

Validate the permission against its corresponding allowed permissions

@param  string $permission The permission to be validated.

@throws \InvalidArgumentException

@return string


private function createPath($share, $directory = '')
    {
        if (empty($directory) && ($directory != '0')) {
            return empty($share) ? '/' : $share;
        }
        $encodedFile = urlencode($directory);
        // Unencode the forward slashes to match what the server expects.
        $encodedFile = str_replace('%2F', '/', $encodedFile);
        // Unencode the backward slashes to match what the server expects.
        $encodedFile = str_replace('%5C', '/', $encodedFile);
        // Re-encode the spaces (encoded as space) to the % encoding.
        $encodedFile = str_replace('+', '%20', $encodedFile);
        // Empty share means accessing default share
        if (empty($share)) {
            return $encodedFile;
        }
        return '/' . $share . '/' . $encodedFile;
    }

Creates URI path for file or share.

@param string $share      The share name.
@param string $directory  The directory name.

@return string


private function getSharePropertiesAsyncImpl(
        $share,
        FileServiceOptions $options = null,
        $operation = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::isTrue(
            $operation == 'properties' || $operation == 'metadata',
            Resources::FILE_SHARE_PROPERTIES_OPERATION_INVALID
        );

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $queryParams = array();
        $postParams  = array();
        $path        = $this->createPath($share);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_REST_TYPE,
            'share'
        );

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        if ($operation == 'metadata') {
            $this->addOptionalQueryParam(
                $queryParams,
                Resources::QP_COMP,
                $operation
            );
        }

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) {
            $responseHeaders = HttpFormatter::formatHeaders($response->getHeaders());
            return GetSharePropertiesResult::create($responseHeaders);
        }, null);
    }

private function getSharePropertiesAsyncImpl ( $ share , FileServiceOptions $ options = null , $ operation = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: isTrue ( $ operation == 'properties' || $ operation == 'metadata' , Resources :: FILE_SHARE_PROPERTIES_OPERATION_INVALID ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ queryParams = array ( ) ; $ postParams = array ( ) ; $ path = $ this -> createPath ( $ share ) ; if ( is_null ( $ options ) ) { $ options = new FileServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_REST_TYPE , 'share' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; if ( $ operation == 'metadata' ) { $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , $ operation ) ; } return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) { $ responseHeaders = HttpFormatter :: formatHeaders ( $ response -> getHeaders ( ) ) ; return GetSharePropertiesResult :: create ( $ responseHeaders ) ; } , null ) ; }

Helper method to create promise for getShareProperties API call.

@param string             $share     The share name.
@param FileServiceOptions $options   The optional parameters.
@param string             $operation The operation string. Should be
'metadata' to set metadata,
and 'properties' to set
properties.

@return \GuzzleHttp\Promise\PromiseInterface

Helper method to create promise for getShareProperties API call .


private function setSharePropertiesAsyncImpl(
        $share,
        array $properties,
        FileServiceOptions $options = null,
        $operation = 'properties'
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::isTrue(
            $operation == 'properties' || $operation == 'metadata',
            Resources::FILE_SHARE_PROPERTIES_OPERATION_INVALID
        );
        Validate::canCastAsString($share, 'share');

        $headers = array();
        if ($operation == 'properties') {
            $headers[Resources::X_MS_SHARE_QUOTA] =
                $properties[Resources::X_MS_SHARE_QUOTA];
        } else {
            Utilities::validateMetadata($properties);
            $headers = $this->generateMetadataHeaders($properties);
        }

        $method      = Resources::HTTP_PUT;
        $postParams  = array();
        $queryParams = array();
        $path        = $this->createPath($share);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_REST_TYPE,
            'share'
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_COMP,
            $operation
        );

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

private function setSharePropertiesAsyncImpl ( $ share , array $ properties , FileServiceOptions $ options = null , $ operation = 'properties' ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: isTrue ( $ operation == 'properties' || $ operation == 'metadata' , Resources :: FILE_SHARE_PROPERTIES_OPERATION_INVALID ) ; Validate :: canCastAsString ( $ share , 'share' ) ; $ headers = array ( ) ; if ( $ operation == 'properties' ) { $ headers [ Resources :: X_MS_SHARE_QUOTA ] = $ properties [ Resources :: X_MS_SHARE_QUOTA ] ; } else { Utilities :: validateMetadata ( $ properties ) ; $ headers = $ this -> generateMetadataHeaders ( $ properties ) ; } $ method = Resources :: HTTP_PUT ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ this -> createPath ( $ share ) ; if ( is_null ( $ options ) ) { $ options = new FileServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_REST_TYPE , 'share' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , $ operation ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) ; }

Helper method to create promise for setShareProperties API call.

@param string             $share      The share name.
@param array              $properties The array that contains
either the properties or
the metadata to be set.
@param FileServiceOptions $options    The optional parameters.
@param string             $operation  The operation string. Should be
'metadata' to set metadata,
and 'properties' to set
properties.

@return \GuzzleHttp\Promise\PromiseInterface

Helper method to create promise for setShareProperties API call .


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

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_COMP,
            'list'
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_PREFIX,
            $options->getPrefix()
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_MARKER,
            $options->getNextMarker()
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_MAX_RESULTS,
            $options->getMaxResults()
        );
        $isInclude = $options->getIncludeMetadata();
        $isInclude = $isInclude ? 'metadata' : null;
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_INCLUDE,
            $isInclude
        );

        $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 ListSharesResult::create(
                $parsed,
                Utilities::getLocationFromHeaders($response->getHeaders())
            );
        });
    }

public function listSharesAsync ( ListSharesOptions $ options = null ) { $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ queryParams = array ( ) ; $ postParams = array ( ) ; $ path = Resources :: EMPTY_STRING ; if ( is_null ( $ options ) ) { $ options = new ListSharesOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , 'list' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_PREFIX , $ options -> getPrefix ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_MARKER , $ options -> getNextMarker ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_MAX_RESULTS , $ options -> getMaxResults ( ) ) ; $ isInclude = $ options -> getIncludeMetadata ( ) ; $ isInclude = $ isInclude ? 'metadata' : null ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_INCLUDE , $ isInclude ) ; $ 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 ListSharesResult :: create ( $ parsed , Utilities :: getLocationFromHeaders ( $ response -> getHeaders ( ) ) ) ; } ) ; }

Create a promise to return a list of the shares under the specified account

@param  ListSharesOptions|null $options The optional parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/list-shares


public function createShare(
        $share,
        CreateShareOptions $options = null
    ) {
        $this->createShareAsync($share, $options)->wait();
    }

public function createShare ( $ share , CreateShareOptions $ options = null ) { $ this -> createShareAsync ( $ share , $ options ) -> wait ( ) ; }

Creates a new share in the given storage account.

@param string                  $share   The share name.
@param CreateShareOptions|null $options The optional parameters.

@return void

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

Creates a new share in the given storage account .


public function createShareAsync(
        $share,
        CreateShareOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::notNullOrEmpty($share, 'share');

        $method      = Resources::HTTP_PUT;
        $postParams  = array();
        $queryParams = array(Resources::QP_REST_TYPE => 'share');
        $path        = $this->createPath($share);

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

        $metadata = $options->getMetadata();
        $headers  = $this->generateMetadataHeaders($metadata);
        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_SHARE_QUOTA,
            $options->getQuota()
        );

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

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

public function createShareAsync ( $ share , CreateShareOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: notNullOrEmpty ( $ share , 'share' ) ; $ method = Resources :: HTTP_PUT ; $ postParams = array ( ) ; $ queryParams = array ( Resources :: QP_REST_TYPE => 'share' ) ; $ path = $ this -> createPath ( $ share ) ; if ( is_null ( $ options ) ) { $ options = new CreateShareOptions ( ) ; } $ metadata = $ options -> getMetadata ( ) ; $ headers = $ this -> generateMetadataHeaders ( $ metadata ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_SHARE_QUOTA , $ options -> getQuota ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_CREATED , Resources :: EMPTY_STRING , $ options ) ; }

Creates promise to create a new share in the given storage account.

@param string                  $share   The share name.
@param CreateShareOptions|null $options The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

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

Creates promise to create a new share in the given storage account .


public function deleteShare(
        $share,
        FileServiceOptions $options = null
    ) {
        $this->deleteShareAsync($share, $options)->wait();
    }

public function deleteShare ( $ share , FileServiceOptions $ options = null ) { $ this -> deleteShareAsync ( $ share , $ options ) -> wait ( ) ; }

Deletes a share in the given storage account.

@param string                  $share   name of the share
@param FileServiceOptions|null $options optional parameters

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-share

Deletes a share in the given storage account .


public function getShareProperties(
        $share,
        FileServiceOptions $options = null
    ) {
        return $this->getSharePropertiesAsync($share, $options)->wait();
    }

public function getShareProperties ( $ share , FileServiceOptions $ options = null ) { return $ this -> getSharePropertiesAsync ( $ share , $ options ) -> wait ( ) ; }

Returns all properties and metadata on the share.

@param string                  $share   name
@param FileServiceOptions|null $options optional parameters

@return GetSharePropertiesResult

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-properties

Returns all properties and metadata on the share .


public function setShareProperties(
        $share,
        $quota,
        FileServiceOptions $options = null
    ) {
        $this->setSharePropertiesAsync($share, $quota, $options)->wait();
    }

public function setShareProperties ( $ share , $ quota , FileServiceOptions $ options = null ) { $ this -> setSharePropertiesAsync ( $ share , $ quota , $ options ) -> wait ( ) ; }

Sets quota of the share.

@param string                  $share   name
@param int                     $quota   quota of the share
@param FileServiceOptions|null $options optional parameters

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-properties


public function setSharePropertiesAsync(
        $share,
        $quota,
        FileServiceOptions $options = null
    ) {
        return $this->setSharePropertiesAsyncImpl(
            $share,
            [Resources::X_MS_SHARE_QUOTA => $quota],
            $options,
            'properties'
        );
    }

public function setSharePropertiesAsync ( $ share , $ quota , FileServiceOptions $ options = null ) { return $ this -> setSharePropertiesAsyncImpl ( $ share , [ Resources :: X_MS_SHARE_QUOTA => $ quota ] , $ options , 'properties' ) ; }

Creates promise to set quota the share.

@param string                  $share   name
@param int                     $quota   quota of the share
@param FileServiceOptions|null $options optional parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-properties

Creates promise to set quota the share .


public function getShareMetadata(
        $share,
        FileServiceOptions $options = null
    ) {
        return $this->getShareMetadataAsync($share, $options)->wait();
    }

public function getShareMetadata ( $ share , FileServiceOptions $ options = null ) { return $ this -> getShareMetadataAsync ( $ share , $ options ) -> wait ( ) ; }

Returns only user-defined metadata for the specified share.

@param string                  $share   name
@param FileServiceOptions|null $options optional parameters

@return GetSharePropertiesResult

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-metadata

Returns only user - defined metadata for the specified share .


public function setShareMetadata(
        $share,
        array $metadata,
        FileServiceOptions $options = null
    ) {
        $this->setShareMetadataAsync($share, $metadata, $options)->wait();
    }

public function setShareMetadata ( $ share , array $ metadata , FileServiceOptions $ options = null ) { $ this -> setShareMetadataAsync ( $ share , $ metadata , $ options ) -> wait ( ) ; }

Updates metadata of the share.

@param string                  $share    name
@param array                   $metadata metadata key/value pair.
@param FileServiceOptions|null $options optional  parameters

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-metadata


public function setShareMetadataAsync(
        $share,
        array $metadata,
        FileServiceOptions $options = null
    ) {
        return $this->setSharePropertiesAsyncImpl(
            $share,
            $metadata,
            $options,
            'metadata'
        );
    }

public function setShareMetadataAsync ( $ share , array $ metadata , FileServiceOptions $ options = null ) { return $ this -> setSharePropertiesAsyncImpl ( $ share , $ metadata , $ options , 'metadata' ) ; }

Creates promise to update metadata headers on the share.

@param string                  $share    name
@param array                   $metadata metadata key/value pair.
@param FileServiceOptions|null $options optional  parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-metadata

Creates promise to update metadata headers on the share .


public function setShareAcl(
        $share,
        ShareACL $acl,
        FileServiceOptions $options = null
    ) {
        $this->setShareAclAsync($share, $acl, $options)->wait();
    }

public function setShareAcl ( $ share , ShareACL $ acl , FileServiceOptions $ options = null ) { $ this -> setShareAclAsync ( $ share , $ acl , $ options ) -> wait ( ) ; }

Sets the ACL and any share-level access policies for the share.

@param string                  $share   name
@param ShareACL                $acl     access control list for share
@param FileServiceOptions|null $options optional parameters

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-acl

Sets the ACL and any share - level access policies for the share .


public function setShareAclAsync(
        $share,
        ShareACL $acl,
        FileServiceOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::notNullOrEmpty($acl, 'acl');

        $method      = Resources::HTTP_PUT;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $this->createPath($share);
        $body        = $acl->toXml($this->dataSerializer);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_REST_TYPE,
            'share'
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_COMP,
            'acl'
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );
        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_TYPE,
            Resources::URL_ENCODED_CONTENT_TYPE
        );

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

public function setShareAclAsync ( $ share , ShareACL $ acl , FileServiceOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: notNullOrEmpty ( $ acl , 'acl' ) ; $ method = Resources :: HTTP_PUT ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ this -> createPath ( $ share ) ; $ body = $ acl -> toXml ( $ this -> dataSerializer ) ; if ( is_null ( $ options ) ) { $ options = new FileServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_REST_TYPE , 'share' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , 'acl' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_TYPE , Resources :: URL_ENCODED_CONTENT_TYPE ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , $ body , $ options ) ; }

Creates promise to set the ACL and any share-level access policies
for the share.

@param string                  $share   name
@param ShareACL                $acl     access control list for share
@param FileServiceOptions|null $options optional parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-acl

Creates promise to set the ACL and any share - level access policies for the share .


public function listDirectoriesAndFiles(
        $share,
        $path = '',
        ListDirectoriesAndFilesOptions $options = null
    ) {
        return $this->listDirectoriesAndFilesAsync($share, $path, $options)->wait();
    }

public function listDirectoriesAndFiles ( $ share , $ path = '' , ListDirectoriesAndFilesOptions $ options = null ) { return $ this -> listDirectoriesAndFilesAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

List directories and files under specified path.

@param  string                              $share   The share that
contains all the
files and directories.
@param  string                              $path    The path to be listed.
@param  ListDirectoriesAndFilesOptions|null $options Optional parameters.

@return ListDirectoriesAndFilesResult

@see https://docs.microsoft.com/en-us/rest/api/storageservices/list-directories-and-files

List directories and files under specified path .


public function listDirectoriesAndFilesAsync(
        $share,
        $path = '',
        ListDirectoriesAndFilesOptions $options = null
    ) {
        Validate::notNull($share, 'share');
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $this->createPath($share, $path);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_REST_TYPE,
            'directory'
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_COMP,
            'list'
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_PREFIX,
            $options->getPrefix()
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_MARKER,
            $options->getNextMarker()
        );
        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_MAX_RESULTS,
            $options->getMaxResults()
        );

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        $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 ListDirectoriesAndFilesResult::create(
                $parsed,
                Utilities::getLocationFromHeaders($response->getHeaders())
            );
        }, null);
    }

public function listDirectoriesAndFilesAsync ( $ share , $ path = '' , ListDirectoriesAndFilesOptions $ options = null ) { Validate :: notNull ( $ share , 'share' ) ; Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( is_null ( $ options ) ) { $ options = new ListDirectoriesAndFilesOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_REST_TYPE , 'directory' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , 'list' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_PREFIX , $ options -> getPrefix ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_MARKER , $ options -> getNextMarker ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_MAX_RESULTS , $ options -> getMaxResults ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ 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 ListDirectoriesAndFilesResult :: create ( $ parsed , Utilities :: getLocationFromHeaders ( $ response -> getHeaders ( ) ) ) ; } , null ) ; }

Creates promise to list directories and files under specified path.

@param  string                              $share   The share that
contains all the
files and directories.
@param  string                              $path    The path to be listed.
@param  ListDirectoriesAndFilesOptions|null $options Optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/list-directories-and-files

Creates promise to list directories and files under specified path .


public function createDirectory(
        $share,
        $path,
        CreateDirectoryOptions $options = null
    ) {
        $this->createDirectoryAsync($share, $path, $options)->wait();
    }

public function createDirectory ( $ share , $ path , CreateDirectoryOptions $ options = null ) { $ this -> createDirectoryAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

Creates a new directory in the given share and path.

@param string                      $share     The share name.
@param string                      $path      The path to create the directory.
@param CreateDirectoryOptions|null $options   The optional parameters.

@return void

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

Creates a new directory in the given share and path .


public function createDirectoryAsync(
        $share,
        $path,
        CreateDirectoryOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');
        Validate::notNullOrEmpty($path, 'path');

        $method      = Resources::HTTP_PUT;
        $postParams  = array();
        $queryParams = array(Resources::QP_REST_TYPE => 'directory');
        $path        = $this->createPath($share, $path);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

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

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

public function createDirectoryAsync ( $ share , $ path , CreateDirectoryOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; Validate :: notNullOrEmpty ( $ path , 'path' ) ; $ method = Resources :: HTTP_PUT ; $ postParams = array ( ) ; $ queryParams = array ( Resources :: QP_REST_TYPE => 'directory' ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( is_null ( $ options ) ) { $ options = new CreateDirectoryOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ metadata = $ options -> getMetadata ( ) ; $ headers = $ this -> generateMetadataHeaders ( $ metadata ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_CREATED , Resources :: EMPTY_STRING , $ options ) ; }

Creates a promise to create a new directory in the given share and path.

@param string                      $share     The share name.
@param string                      $path      The path to create the directory.
@param CreateDirectoryOptions|null $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

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

Creates a promise to create a new directory in the given share and path .


public function deleteDirectory(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        $this->deleteDirectoryAsync($share, $path, $options)->wait();
    }

public function deleteDirectory ( $ share , $ path , FileServiceOptions $ options = null ) { $ this -> deleteDirectoryAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

Deletes a directory in the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path to delete the directory.
@param FileServiceOptions|null $options   The optional parameters.

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-directory

Deletes a directory in the given share and path .


public function getDirectoryProperties(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        return $this->getDirectoryPropertiesAsync($share, $path, $options)->wait();
    }

public function getDirectoryProperties ( $ share , $ path , FileServiceOptions $ options = null ) { return $ this -> getDirectoryPropertiesAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

Gets a directory's properties from the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path of the directory.
@param FileServiceOptions|null $options   The optional parameters.

@return GetDirectoryPropertiesResult

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-properties

Gets a directory s properties from the given share and path .


public function getDirectoryPropertiesAsync(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $postParams  = array();
        $queryParams = array(Resources::QP_REST_TYPE => 'directory');
        $path        = $this->createPath($share, $path);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) {
            $parsed = HttpFormatter::formatHeaders($response->getHeaders());
            return GetDirectoryPropertiesResult::create($parsed);
        }, null);
    }

public function getDirectoryPropertiesAsync ( $ share , $ path , FileServiceOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( Resources :: QP_REST_TYPE => 'directory' ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( is_null ( $ options ) ) { $ options = new FileServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) { $ parsed = HttpFormatter :: formatHeaders ( $ response -> getHeaders ( ) ) ; return GetDirectoryPropertiesResult :: create ( $ parsed ) ; } , null ) ; }

Creates promise to get a directory's properties from the given share
and path.

@param string                  $share     The share name.
@param string                  $path      The path of the directory.
@param FileServiceOptions|null $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-properties

Creates promise to get a directory s properties from the given share and path .


public function getDirectoryMetadata(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        return $this->getDirectoryMetadataAsync($share, $path, $options)->wait();
    }

public function getDirectoryMetadata ( $ share , $ path , FileServiceOptions $ options = null ) { return $ this -> getDirectoryMetadataAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

Gets a directory's metadata from the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path of the directory.
@param FileServiceOptions|null $options   The optional parameters.

@return GetDirectoryMetadataResult

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-metadata

Gets a directory s metadata from the given share and path .


public function setDirectoryMetadata(
        $share,
        $path,
        array $metadata,
        FileServiceOptions $options = null
    ) {
        $this->setDirectoryMetadataAsync(
            $share,
            $path,
            $metadata,
            $options
        )->wait();
    }

public function setDirectoryMetadata ( $ share , $ path , array $ metadata , FileServiceOptions $ options = null ) { $ this -> setDirectoryMetadataAsync ( $ share , $ path , $ metadata , $ options ) -> wait ( ) ; }

Sets a directory's metadata from the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path to delete the directory.
@param array                   $metadata  The metadata to be set.
@param FileServiceOptions|null $options   The optional parameters.

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-directory-metadata

Sets a directory s metadata from the given share and path .


public function createFile(
        $share,
        $path,
        $size,
        CreateFileOptions $options = null
    ) {
        return $this->createFileAsync(
            $share,
            $path,
            $size,
            $options
        )->wait();
    }

public function createFile ( $ share , $ path , $ size , CreateFileOptions $ options = null ) { return $ this -> createFileAsync ( $ share , $ path , $ size , $ options ) -> wait ( ) ; }

Create a new file.

@param string                 $share   The share name.
@param string                 $path    The path and name of the file.
@param int                    $size    The size of the file.
@param CreateFileOptions|null $options The optional parameters.

@return void

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


public function createFileAsync(
        $share,
        $path,
        $size,
        CreateFileOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::notNullOrEmpty($share, 'share');
        Validate::canCastAsString($path, 'path');
        Validate::notNullOrEmpty($path, 'path');
        Validate::isInteger($size, 'size');

        $method      = Resources::HTTP_PUT;
        $postParams  = array();
        $queryParams = array();
        $path        = $this->createPath($share, $path);

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

        Utilities::validateMetadata($options->getMetadata());
        $headers = $this->generateMetadataHeaders($options->getMetadata());

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_TYPE,
            'file'
        );

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_CONTENT_LENGTH,
            $size
        );

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

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_ENCODING,
            $options->getContentEncoding()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_LANGUAGE,
            $options->getContentLanguage()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::CACHE_CONTROL,
            $options->getCacheControl()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::FILE_CONTENT_MD5,
            $options->getContentMD5()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_DISPOSITION,
            $options->getContentDisposition()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_DISPOSITION,
            $options->getContentDisposition()
        );

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

public function createFileAsync ( $ share , $ path , $ size , CreateFileOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: notNullOrEmpty ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; Validate :: notNullOrEmpty ( $ path , 'path' ) ; Validate :: isInteger ( $ size , 'size' ) ; $ method = Resources :: HTTP_PUT ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( is_null ( $ options ) ) { $ options = new CreateFileOptions ( ) ; } Utilities :: validateMetadata ( $ options -> getMetadata ( ) ) ; $ headers = $ this -> generateMetadataHeaders ( $ options -> getMetadata ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_TYPE , 'file' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_CONTENT_LENGTH , $ size ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_TYPE , $ options -> getContentType ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_ENCODING , $ options -> getContentEncoding ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_LANGUAGE , $ options -> getContentLanguage ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CACHE_CONTROL , $ options -> getCacheControl ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: FILE_CONTENT_MD5 , $ options -> getContentMD5 ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_DISPOSITION , $ options -> getContentDisposition ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_DISPOSITION , $ options -> getContentDisposition ( ) ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_CREATED , Resources :: EMPTY_STRING , $ options ) ; }

Creates promise to create a new file.

@param string                 $share   The share name.
@param string                 $path    The path and name of the file.
@param int                    $size    The size of the file.
@param CreateFileOptions|null $options The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

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


public function deleteFile(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        $this->deleteFileAsync($share, $path, $options)->wait();
    }

public function deleteFile ( $ share , $ path , FileServiceOptions $ options = null ) { $ this -> deleteFileAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

Deletes a file in the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path to delete the file.
@param FileServiceOptions|null $options   The optional parameters.

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2

Deletes a file in the given share and path .


public function deleteFileAsync(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');

        $method      = Resources::HTTP_DELETE;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $this->createPath($share, $path);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

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

public function deleteFileAsync ( $ share , $ path , FileServiceOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; $ method = Resources :: HTTP_DELETE ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( is_null ( $ options ) ) { $ options = new FileServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_ACCEPTED , Resources :: EMPTY_STRING , $ options ) ; }

Creates a promise to delete a new file in the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path to delete the file.
@param FileServiceOptions|null $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2

Creates a promise to delete a new file in the given share and path .


public function getFile(
        $share,
        $path,
        GetFileOptions $options = null
    ) {
        return $this->getFileAsync($share, $path, $options)->wait();
    }

public function getFile ( $ share , $ path , GetFileOptions $ options = null ) { return $ this -> getFileAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

Reads or downloads a file from the server, including its metadata and
properties.

@param string              $share   name of the share
@param string              $path    path of the file to be get
@param GetFileOptions|null $options optional parameters

@return GetFileResult

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file

Reads or downloads a file from the server including its metadata and properties .


public function getFileAsync(
        $share,
        $path,
        GetFileOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');

        $method      = Resources::HTTP_GET;
        $headers     = array();
        $postParams  = array();
        $queryParams = array();
        $path        = $this->createPath($share, $path);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_RANGE,
            $options->getRangeString() == '' ? null : $options->getRangeString()
        );
        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_RANGE_GET_CONTENT_MD5,
            $options->getRangeGetContentMD5() ? 'true' : null
        );

        $options->setIsStreaming(true);

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            array(Resources::STATUS_OK, Resources::STATUS_PARTIAL_CONTENT),
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) {
            $metadata = Utilities::getMetadataArray(
                HttpFormatter::formatHeaders($response->getHeaders())
            );

            return GetFileResult::create(
                HttpFormatter::formatHeaders($response->getHeaders()),
                $response->getBody(),
                $metadata
            );
        });
    }

public function getFileAsync ( $ share , $ path , GetFileOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; $ method = Resources :: HTTP_GET ; $ headers = array ( ) ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( is_null ( $ options ) ) { $ options = new GetFileOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_RANGE , $ options -> getRangeString ( ) == '' ? null : $ options -> getRangeString ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_RANGE_GET_CONTENT_MD5 , $ options -> getRangeGetContentMD5 ( ) ? 'true' : null ) ; $ options -> setIsStreaming ( true ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , array ( Resources :: STATUS_OK , Resources :: STATUS_PARTIAL_CONTENT ) , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) { $ metadata = Utilities :: getMetadataArray ( HttpFormatter :: formatHeaders ( $ response -> getHeaders ( ) ) ) ; return GetFileResult :: create ( HttpFormatter :: formatHeaders ( $ response -> getHeaders ( ) ) , $ response -> getBody ( ) , $ metadata ) ; } ) ; }

Creates promise to read or download a file from the server, including its
metadata and properties.

@param string              $share   name of the share
@param string              $path    path of the file to be get
@param GetFileOptions|null $options optional parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file

Creates promise to read or download a file from the server including its metadata and properties .


public function getFileProperties(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        return $this->getFilePropertiesAsync($share, $path, $options)->wait();
    }

public function getFileProperties ( $ share , $ path , FileServiceOptions $ options = null ) { return $ this -> getFilePropertiesAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

Gets a file's properties from the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path to delete the file.
@param FileServiceOptions|null $options   The optional parameters.

@return FileProperties

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-properties

Gets a file s properties from the given share and path .


public function getFilePropertiesAsync(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');

        $method      = Resources::HTTP_HEAD;
        $headers     = array();
        $queryParams  = array();
        $postParams  = array();
        $path        = $this->createPath($share, $path);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        return $this->sendAsync(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            Resources::STATUS_OK,
            Resources::EMPTY_STRING,
            $options
        )->then(function ($response) {
            $parsed = HttpFormatter::formatHeaders($response->getHeaders());
            return FileProperties::createFromHttpHeaders($parsed);
        }, null);
    }

public function getFilePropertiesAsync ( $ share , $ path , FileServiceOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; $ method = Resources :: HTTP_HEAD ; $ headers = array ( ) ; $ queryParams = array ( ) ; $ postParams = array ( ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( is_null ( $ options ) ) { $ options = new FileServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) -> then ( function ( $ response ) { $ parsed = HttpFormatter :: formatHeaders ( $ response -> getHeaders ( ) ) ; return FileProperties :: createFromHttpHeaders ( $ parsed ) ; } , null ) ; }

Creates promise to get a file's properties from the given share
and path.

@param string                  $share     The share name.
@param string                  $path      The path to delete the file.
@param FileServiceOptions|null $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-properties

Creates promise to get a file s properties from the given share and path .


public function setFileProperties(
        $share,
        $path,
        FileProperties $properties,
        FileServiceOptions $options = null
    ) {
        $this->setFilePropertiesAsync($share, $path, $properties, $options)->wait();
    }

public function setFileProperties ( $ share , $ path , FileProperties $ properties , FileServiceOptions $ options = null ) { $ this -> setFilePropertiesAsync ( $ share , $ path , $ properties , $ options ) -> wait ( ) ; }

Sets properties on the file.

@param string                  $share      share name
@param string                  $path       path of the file
@param FileProperties          $properties file properties.
@param FileServiceOptions|null $options    optional     parameters

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties


public function setFilePropertiesAsync(
        $share,
        $path,
        FileProperties $properties,
        FileServiceOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');

        $headers = array();

        $method      = Resources::HTTP_PUT;
        $postParams  = array();
        $queryParams = array(Resources::QP_COMP => 'properties');
        $path        = $this->createPath($share, $path);

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_CACHE_CONTROL,
            $properties->getCacheControl()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_CONTENT_TYPE,
            $properties->getContentType()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_CONTENT_MD5,
            $properties->getContentMD5()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_CONTENT_ENCODING,
            $properties->getContentEncoding()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_CONTENT_LANGUAGE,
            $properties->getContentLanguage()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_CONTENT_DISPOSITION,
            $properties->getContentDisposition()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_CONTENT_LENGTH,
            $properties->getContentLength()
        );

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

public function setFilePropertiesAsync ( $ share , $ path , FileProperties $ properties , FileServiceOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; $ headers = array ( ) ; $ method = Resources :: HTTP_PUT ; $ postParams = array ( ) ; $ queryParams = array ( Resources :: QP_COMP => 'properties' ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( is_null ( $ options ) ) { $ options = new FileServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_CACHE_CONTROL , $ properties -> getCacheControl ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_CONTENT_TYPE , $ properties -> getContentType ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_CONTENT_MD5 , $ properties -> getContentMD5 ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_CONTENT_ENCODING , $ properties -> getContentEncoding ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_CONTENT_LANGUAGE , $ properties -> getContentLanguage ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_CONTENT_DISPOSITION , $ properties -> getContentDisposition ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_CONTENT_LENGTH , $ properties -> getContentLength ( ) ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) ; }

Creates promise to set properties on the file.

@param string                  $share      share name
@param string                  $path       path of the file
@param FileProperties          $properties file properties.
@param FileServiceOptions|null $options    optional     parameters

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties

Creates promise to set properties on the file .


public function getFileMetadata(
        $share,
        $path,
        FileServiceOptions $options = null
    ) {
        return $this->getFileMetadataAsync($share, $path, $options)->wait();
    }

public function getFileMetadata ( $ share , $ path , FileServiceOptions $ options = null ) { return $ this -> getFileMetadataAsync ( $ share , $ path , $ options ) -> wait ( ) ; }

Gets a file's metadata from the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path of the file.
@param FileServiceOptions|null $options   The optional parameters.

@return GetFileMetadataResult

@see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-metadata

Gets a file s metadata from the given share and path .


public function setFileMetadata(
        $share,
        $path,
        array $metadata,
        FileServiceOptions $options = null
    ) {
        return $this->setFileMetadataAsync(
            $share,
            $path,
            $metadata,
            $options
        )->wait();
    }

public function setFileMetadata ( $ share , $ path , array $ metadata , FileServiceOptions $ options = null ) { return $ this -> setFileMetadataAsync ( $ share , $ path , $ metadata , $ options ) -> wait ( ) ; }

Sets a file's metadata from the given share and path.

@param string                  $share     The share name.
@param string                  $path      The path to delete the file.
@param array                   $metadata  The metadata to be set.
@param FileServiceOptions|null $options   The optional parameters.

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-metadata

Sets a file s metadata from the given share and path .


public function setFileMetadataAsync(
        $share,
        $path,
        array $metadata,
        FileServiceOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');

        $method      = Resources::HTTP_PUT;
        $postParams  = array();
        $queryParams = array();
        $path        = $this->createPath($share, $path);

        Utilities::validateMetadata($metadata);
        $headers = $this->generateMetadataHeaders($metadata);
        if (is_null($options)) {
            $options = new FileServiceOptions();
        }

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

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

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

public function setFileMetadataAsync ( $ share , $ path , array $ metadata , FileServiceOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; $ method = Resources :: HTTP_PUT ; $ postParams = array ( ) ; $ queryParams = array ( ) ; $ path = $ this -> createPath ( $ share , $ path ) ; Utilities :: validateMetadata ( $ metadata ) ; $ headers = $ this -> generateMetadataHeaders ( $ metadata ) ; if ( is_null ( $ options ) ) { $ options = new FileServiceOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , 'metadata' ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_OK , Resources :: EMPTY_STRING , $ options ) ; }

Creates promise to set a file's metadata from the given share
and path.

@param string                  $share     The share name.
@param string                  $path      The path to delete the file.
@param array                   $metadata  The metadata to be set.
@param FileServiceOptions|null $options   The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-metadata

Creates promise to set a file s metadata from the given share and path .


public function putFileRange(
        $share,
        $path,
        $content,
        Range $range,
        PutFileRangeOptions $options = null
    ) {
        $this->putFileRangeAsync(
            $share,
            $path,
            $content,
            $range,
            $options
        )->wait();
    }

public function putFileRange ( $ share , $ path , $ content , Range $ range , PutFileRangeOptions $ options = null ) { $ this -> putFileRangeAsync ( $ share , $ path , $ content , $ range , $ options ) -> wait ( ) ; }

Writes range of bytes to a file. Range can be at most 4MB in length.

@param  string                          $share   The share name.
@param  string                          $path    The path of the file.
@param  string|resource|StreamInterface $content The content to be uploaded.
@param  Range                           $range   The range in the file to
be put.
@param  PutFileRangeOptions|null        $options The optional parameters.

@return void

@see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range

Writes range of bytes to a file . Range can be at most 4MB in length .


public function putFileRangeAsync(
        $share,
        $path,
        $content,
        Range $range,
        PutFileRangeOptions $options = null
    ) {
        Validate::canCastAsString($share, 'share');
        Validate::canCastAsString($path, 'path');
        Validate::notNullOrEmpty($path, 'path');
        Validate::notNullOrEmpty($share, 'share');
        Validate::notNull($range->getLength(), Resources::RESOURCE_RANGE_LENGTH_MUST_SET);
        $stream = Psr7\stream_for($content);

        $method      = Resources::HTTP_PUT;
        $headers     = array();
        $queryParams = array();
        $postParams  = array();
        $path        = $this->createPath($share, $path);

        if ($options == null) {
            $options = new PutFileRangeOptions();
        }

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_RANGE,
            $range->getRangeString()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_LENGTH,
            $range->getLength()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_WRITE,
            'Update'
        );

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_MD5,
            $options->getContentMD5()
        );

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

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

public function putFileRangeAsync ( $ share , $ path , $ content , Range $ range , PutFileRangeOptions $ options = null ) { Validate :: canCastAsString ( $ share , 'share' ) ; Validate :: canCastAsString ( $ path , 'path' ) ; Validate :: notNullOrEmpty ( $ path , 'path' ) ; Validate :: notNullOrEmpty ( $ share , 'share' ) ; Validate :: notNull ( $ range -> getLength ( ) , Resources :: RESOURCE_RANGE_LENGTH_MUST_SET ) ; $ stream = Psr7 \ stream_for ( $ content ) ; $ method = Resources :: HTTP_PUT ; $ headers = array ( ) ; $ queryParams = array ( ) ; $ postParams = array ( ) ; $ path = $ this -> createPath ( $ share , $ path ) ; if ( $ options == null ) { $ options = new PutFileRangeOptions ( ) ; } $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_TIMEOUT , $ options -> getTimeout ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_RANGE , $ range -> getRangeString ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_LENGTH , $ range -> getLength ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: X_MS_WRITE , 'Update' ) ; $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_MD5 , $ options -> getContentMD5 ( ) ) ; $ this -> addOptionalQueryParam ( $ queryParams , Resources :: QP_COMP , 'range' ) ; return $ this -> sendAsync ( $ method , $ headers , $ queryParams , $ postParams , $ path , Resources :: STATUS_CREATED , $ stream , $ options ) ; }

Creates promise to write range of bytes to a file. Range can be at most
4MB in length.

@param  string                          $share   The share name.
@param  string                          $path    The path of the file.
@param  string|resource|StreamInterface $content The content to be uploaded.
@param  Range                           $range   The range in the file to
be put.
@param  PutFileRangeOptions|null        $options The optional parameters.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range

Creates promise to write range of bytes to a file . Range can be at most 4MB in length .


public function createFileFromContent(
        $share,
        $path,
        $content,
        CreateFileFromContentOptions $options = null
    ) {
        $this->createFileFromContentAsync($share, $path, $content, $options)->wait();
    }

public function createFileFromContent ( $ share , $ path , $ content , CreateFileFromContentOptions $ options = null ) { $ this -> createFileFromContentAsync ( $ share , $ path , $ content , $ options ) -> wait ( ) ; }

Creates a file from a provided content.

@param  string                             $share   the share name
@param  string                             $path    the path of the file
@param  StreamInterface|resource|string    $content the content used to
create the file
@param  CreateFileFromContentOptions|null  $options optional parameters

@return void

Creates a file from a provided content .