diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 940794e..0000000 --- a/.gitignore +++ /dev/null @@ -1,288 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Typescript v1 declaration files -typings/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs diff --git a/ChangeLog.md b/ChangeLog.md index 7e51909..adcce04 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,11 @@ +2018.04 - version 1.1.0 + +* MD files are modified for better readability and formatting. +* CACERT can now be set when creating RestProxies using `$options` parameter. +* Removed unnecessary trailing spaces. +* Assertions are re-factored in test cases. +* Now the test framework uses `PHPUnit\Framework\TestCase` instead of `PHPUnit_Framework_TestCase`. + 2018.01 - version 1.0.0 * Created `QueueSharedAccessSignatureHelper` and moved method `SharedAccessSignatureHelper::generateQueueServiceSharedAccessSignatureToken()` into `QueueSharedAccessSignatureHelper`. diff --git a/README.md b/README.md index dac9526..7e9d679 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This project provides a PHP client library that makes it easy to access Microsof [![Latest Stable Version](https://poser.pugx.org/microsoft/azure-storage-queue/v/stable)](https://packagist.org/packages/microsoft/azure-storage-queue) > **Note** -> +> > * This [repository](https://github.com/azure/azure-storage-queue-php) is currently used for releasing only, please go to [azure-storage-php](https://github.com/azure/azure-storage-php) for submitting issues or contribution. > * If you are looking for the Service Bus, Service Runtime, Service Management or Media Services libraries, please visit https://github.com/Azure/azure-sdk-for-php. > * If you need big file (larger than 2GB) or 64-bit integer support, please install PHP 7 64-bit version. @@ -24,70 +24,82 @@ Please check details on [API reference documents](http://azure.github.io/azure-s * PHP 5.6 or above * See [composer.json](composer.json) for dependencies * Required extension for PHP: - php_fileinfo.dll - php_mbstring.dll - php_openssl.dll - php_xsl.dll + * php_fileinfo.dll + * php_mbstring.dll + * php_openssl.dll + * php_xsl.dll * Recommended extension for PHP: - php_curl.dll + * php_curl.dll ## Download Source Code To get the source code from GitHub, type - git clone https://github.com/Azure/azure-storage-php.git - cd ./azure-storage-php - +``` +git clone https://github.com/Azure/azure-storage-php.git +cd ./azure-storage-php +``` ## Install via Composer 1. Create a file named **composer.json** in the root of your project and add the following code to it: ```json - { - "require": { - "microsoft/azure-storage-queue": "*" - } - } +{ + "require": { + "microsoft/azure-storage-queue": "*" + } +} ``` 2. Download **[composer.phar](http://getcomposer.org/composer.phar)** in your project root. 3. Open a command prompt and execute this in your project root - php composer.phar install +``` +php composer.phar install +``` ## Usage -There are four basic steps that have to be performed before you can make a call to any Microsoft Azure Storage API when using the libraries. +There are four basic steps that have to be performed before you can make a call to any Microsoft Azure Storage API when using the libraries. * First, include the autoloader script: - - require_once "vendor/autoload.php"; - + +```php +require_once "vendor/autoload.php"; +``` + * Include the namespaces you are going to use. To create any Microsoft Azure service client you need to use the rest proxy classes, such as **QueueRestProxy** class: - use MicrosoftAzure\Storage\Queue\QueueRestProxy; +```php +use MicrosoftAzure\Storage\Queue\QueueRestProxy; +``` To process exceptions you need: - use MicrosoftAzure\Storage\Common\ServiceException; +```php +use MicrosoftAzure\Storage\Common\ServiceException; +``` - -* To instantiate the service client you will also need a valid [connection string](https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/). The format is: +* To instantiate the service client you will also need a valid [connection string](https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/). The format is: - DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey] +``` +DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey] +``` or: - - QueueEndpoint=[myQueueEndpoint];SharedAccessSignature=[sasToken] - + +``` +QueueEndpoint=[myQueueEndpoint];SharedAccessSignature=[sasToken] +``` + * Instantiate a client object - a wrapper around the available calls for the given service. - ```PHP - $queueClient = QueueRestProxy::createQueueService($connectionString); - ``` +```php +$queueClient = QueueRestProxy::createQueueService($connectionString); +``` ### Using Middlewares To specify the middlewares, user have to create an array with middlewares and put it in the `$requestOptions` with key 'middlewares'. The sequence of @@ -100,7 +112,7 @@ services' `$_options` instead when creating them if the middleware is to be applied to each of the API call for a rest proxy. These middlewares will always be invoked after the middlewares in the `$requestOptions`. e.g.: -``` +```php $queueClient = QueueRestProxy::createQueueService( $connectionString, $optionsWithMiddlewares @@ -120,12 +132,19 @@ To use proxies during HTTP requests, set system variable `HTTP_PROXY` and the pr ### Error: Unable to get local issuer certificate cURL can't verify the validity of Microsoft certificate when trying to issue a request call to Azure Storage Services. You must configure cURL to use a certificate when issuing https requests by the following steps: -1. Download the cacert.pem file from [cURL site](http://curl.haxx.se/docs/caextract.html). -2. Open your php.ini file and add the following line: +1. Download the cacert.pem file from [cURL site](http://curl.haxx.se/docs/caextract.html). - ``` - curl.cainfo = "" - ``` +2. Then either: + * Open your php.ini file and add the following line: + ```ini + curl.cainfo = "" + ``` + OR + * Point to the cacert in the options when creating the Proxy. + ```php + $options["http"] = ["verify" => ""]; + QueueRestProxy::createQueueService($connectionString, $options); + ``` ## Code samples @@ -137,7 +156,7 @@ You can find samples in the [sample folder](samples) If you are using [Azure SDK for PHP](https://github.com/Azure/azure-sdk-for-php/) to access Azure Storage Service, we highly recommend you to migrate to this SDK for faster issue resolution and quicker feature implementation. We are working on supporting the latest service features as well as improvement on existing APIs. For now, Microsoft Azure Storage PHP client libraries share almost the same interface as the storage blobs, tables, queues and files APIs in Azure SDK for PHP. However, there are some minor breaking changes need to be addressed during your migration. You can find the details in [BreakingChanges.md](BreakingChanges.md). - + # Need Help? Be sure to check out the Microsoft Azure [Developer Forums on Stack Overflow](http://go.microsoft.com/fwlink/?LinkId=234489) and [github issues](https://github.com/Azure/azure-storage-php/issues) if you have trouble with the provided code. @@ -146,5 +165,5 @@ Be sure to check out the Microsoft Azure [Developer Forums on Stack Overflow](ht If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/). You can find more details for contributing in the [CONTRIBUTING.md](CONTRIBUTING.md). - -If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-storage-php/issues) section of the project. \ No newline at end of file + +If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-storage-php/issues) section of the project. diff --git a/composer.json b/composer.json index 5ebced0..adda005 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "microsoft/azure-storage-queue", - "version": "1.0.0", + "version": "1.1.0", "description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Queue APIs.", "keywords": [ "php", "azure", "storage", "sdk", "queue" ], "license": "MIT", @@ -12,7 +12,7 @@ ], "require": { "php": ">=5.6.0", - "microsoft/azure-storage-common": "~1.0" + "microsoft/azure-storage-common": "~1.1" }, "autoload": { "psr-4": { diff --git a/src/Queue/Internal/QueueResources.php b/src/Queue/Internal/QueueResources.php index 7b39257..befaa2e 100644 --- a/src/Queue/Internal/QueueResources.php +++ b/src/Queue/Internal/QueueResources.php @@ -41,7 +41,7 @@ class QueueResources extends Resources { // @codingStandardsIgnoreStart - const QUEUE_SDK_VERSION = '1.0.0'; + const QUEUE_SDK_VERSION = '1.1.0'; const STORAGE_API_LATEST_VERSION = '2016-05-31'; // Error messages diff --git a/src/Queue/Models/CreateMessageOptions.php b/src/Queue/Models/CreateMessageOptions.php index daeb4a7..310e9e1 100644 --- a/src/Queue/Models/CreateMessageOptions.php +++ b/src/Queue/Models/CreateMessageOptions.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; /** @@ -38,7 +38,7 @@ class CreateMessageOptions extends QueueServiceOptions { private $_visibilityTimeoutInSeconds; private $_timeToLiveInSeconds; - + /** * Gets visibilityTimeoutInSeconds field. * @@ -48,7 +48,7 @@ public function getVisibilityTimeoutInSeconds() { return $this->_visibilityTimeoutInSeconds; } - + /** * Sets visibilityTimeoutInSeconds field. * @@ -60,7 +60,7 @@ public function setVisibilityTimeoutInSeconds($visibilityTimeoutInSeconds) { $this->_visibilityTimeoutInSeconds = $visibilityTimeoutInSeconds; } - + /** * Gets timeToLiveInSeconds field. * @@ -70,7 +70,7 @@ public function getTimeToLiveInSeconds() { return $this->_timeToLiveInSeconds; } - + /** * Sets timeToLiveInSeconds field. * diff --git a/src/Queue/Models/CreateQueueOptions.php b/src/Queue/Models/CreateQueueOptions.php index 8b1baa9..6d6a115 100644 --- a/src/Queue/Models/CreateQueueOptions.php +++ b/src/Queue/Models/CreateQueueOptions.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; /** @@ -37,7 +37,7 @@ class CreateQueueOptions extends QueueServiceOptions { private $_metadata; - + /** * Gets user defined metadata. * @@ -47,7 +47,7 @@ public function getMetadata() { return $this->_metadata; } - + /** * Sets user defined metadata. This metadata should be added without the header * prefix (x-ms-meta-*). @@ -60,7 +60,7 @@ public function setMetadata(array $metadata) { $this->_metadata = $metadata; } - + /** * Adds new metadata element. This element should be added without the header * prefix (x-ms-meta-*). diff --git a/src/Queue/Models/GetQueueMetadataResult.php b/src/Queue/Models/GetQueueMetadataResult.php index 07afe1f..cc1ef00 100644 --- a/src/Queue/Models/GetQueueMetadataResult.php +++ b/src/Queue/Models/GetQueueMetadataResult.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; /** @@ -38,7 +38,7 @@ class GetQueueMetadataResult { private $_approximateMessageCount; private $_metadata; - + /** * Constructor * @@ -52,7 +52,7 @@ public function __construct($approximateMessageCount, array $metadata) $this->setApproximateMessageCount($approximateMessageCount); $this->setMetadata(is_null($metadata) ? array() : $metadata); } - + /** * Gets approximate message count. * @@ -62,7 +62,7 @@ public function getApproximateMessageCount() { return $this->_approximateMessageCount; } - + /** * Sets approximate message count. * @@ -76,7 +76,7 @@ protected function setApproximateMessageCount($approximateMessageCount) { $this->_approximateMessageCount = $approximateMessageCount; } - + /** * Sets metadata. * @@ -86,7 +86,7 @@ public function getMetadata() { return $this->_metadata; } - + /** * Sets metadata. * diff --git a/src/Queue/Models/ListMessagesOptions.php b/src/Queue/Models/ListMessagesOptions.php index 4d4854c..d828e7d 100644 --- a/src/Queue/Models/ListMessagesOptions.php +++ b/src/Queue/Models/ListMessagesOptions.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; /** @@ -38,7 +38,7 @@ class ListMessagesOptions extends QueueServiceOptions { private $_numberOfMessages; private $_visibilityTimeoutInSeconds; - + /** * Gets visibilityTimeoutInSeconds field. * @@ -48,7 +48,7 @@ public function getVisibilityTimeoutInSeconds() { return $this->_visibilityTimeoutInSeconds; } - + /** * Sets visibilityTimeoutInSeconds field. * @@ -60,7 +60,7 @@ public function setVisibilityTimeoutInSeconds($visibilityTimeoutInSeconds) { $this->_visibilityTimeoutInSeconds = $visibilityTimeoutInSeconds; } - + /** * Gets numberOfMessages field. * @@ -70,7 +70,7 @@ public function getNumberOfMessages() { return $this->_numberOfMessages; } - + /** * Sets numberOfMessages field. * diff --git a/src/Queue/Models/ListMessagesResult.php b/src/Queue/Models/ListMessagesResult.php index 0a61b15..a902623 100644 --- a/src/Queue/Models/ListMessagesResult.php +++ b/src/Queue/Models/ListMessagesResult.php @@ -39,7 +39,7 @@ class ListMessagesResult { private $_queueMessages; - + /** * Creates ListMessagesResult object from parsed XML response. * @@ -53,20 +53,20 @@ public static function create(array $parsedResponse = null) { $result = new ListMessagesResult(); $queueMessages = array(); - + if (!empty($parsedResponse)) { $rawMessages = Utilities::getArray($parsedResponse['QueueMessage']); foreach ($rawMessages as $value) { $message = QueueMessage::createFromListMessages($value); - + $queueMessages[] = $message; } } $result->setQueueMessages($queueMessages); - + return $result; } - + /** * Gets queueMessages field. * @@ -76,7 +76,7 @@ public function getQueueMessages() { return $this->_queueMessages; } - + /** * Sets queueMessages field. * @@ -89,7 +89,7 @@ public function getQueueMessages() protected function setQueueMessages($queueMessages) { $this->_queueMessages = array(); - + foreach ($queueMessages as $value) { $this->_queueMessages[] = clone $value; } diff --git a/src/Queue/Models/ListQueuesOptions.php b/src/Queue/Models/ListQueuesOptions.php index cc1638e..6a82614 100644 --- a/src/Queue/Models/ListQueuesOptions.php +++ b/src/Queue/Models/ListQueuesOptions.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; diff --git a/src/Queue/Models/ListQueuesResult.php b/src/Queue/Models/ListQueuesResult.php index 3dd4697..39d6707 100644 --- a/src/Queue/Models/ListQueuesResult.php +++ b/src/Queue/Models/ListQueuesResult.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; use MicrosoftAzure\Storage\Common\Models\MarkerContinuationToken; @@ -97,11 +97,11 @@ public static function create(array $parsedResponse, $location = '') )); $queues = array(); $rawQueues = array(); - + if (!empty($parsedResponse['Queues'])) { $rawQueues = Utilities::getArray($parsedResponse['Queues']['Queue']); } - + foreach ($rawQueues as $value) { $queue = new Queue($value['Name'], $serviceEndpoint . $value['Name']); $metadata = Utilities::tryGetValue($value, Resources::QP_METADATA); @@ -121,7 +121,7 @@ public function getQueues() { return $this->_queues; } - + /** * Sets queues. * diff --git a/src/Queue/Models/PeekMessagesOptions.php b/src/Queue/Models/PeekMessagesOptions.php index b525cbb..c520509 100644 --- a/src/Queue/Models/PeekMessagesOptions.php +++ b/src/Queue/Models/PeekMessagesOptions.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; /** @@ -37,7 +37,7 @@ class PeekMessagesOptions extends QueueServiceOptions { private $_numberOfMessages; - + /** * Gets numberOfMessages field. * @@ -47,7 +47,7 @@ public function getNumberOfMessages() { return $this->_numberOfMessages; } - + /** * Sets numberOfMessages field. * diff --git a/src/Queue/Models/PeekMessagesResult.php b/src/Queue/Models/PeekMessagesResult.php index e9c8c35..55c75e1 100644 --- a/src/Queue/Models/PeekMessagesResult.php +++ b/src/Queue/Models/PeekMessagesResult.php @@ -40,7 +40,7 @@ class PeekMessagesResult { private $queueMessages; - + /** * Creates PeekMessagesResult object from parsed XML response. * @@ -54,22 +54,22 @@ public static function create($parsedResponse) { $result = new PeekMessagesResult(); $queueMessages = array(); - + if (!empty($parsedResponse)) { $rawMessages = Utilities::getArray( $parsedResponse[Resources::QP_QUEUE_MESSAGE] ); foreach ($rawMessages as $value) { $message = QueueMessage::createFromPeekMessages($value); - + $queueMessages[] = $message; } } $result->setQueueMessages($queueMessages); - + return $result; } - + /** * Gets queueMessages field. * @@ -78,14 +78,14 @@ public static function create($parsedResponse) public function getQueueMessages() { $clonedMessages = array(); - + foreach ($this->queueMessages as $value) { $clonedMessages[] = clone $value; } - + return $clonedMessages; } - + /** * Sets queueMessages field. * diff --git a/src/Queue/Models/Queue.php b/src/Queue/Models/Queue.php index 6176cad..f7a39dc 100644 --- a/src/Queue/Models/Queue.php +++ b/src/Queue/Models/Queue.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; /** diff --git a/src/Queue/Models/QueueACL.php b/src/Queue/Models/QueueACL.php index 9e1c4b4..3bdb2b2 100644 --- a/src/Queue/Models/QueueACL.php +++ b/src/Queue/Models/QueueACL.php @@ -63,7 +63,7 @@ public static function create(array $parsed = null) { $result = new QueueACL(); $result->fromXmlArray($parsed); - + return $result; } diff --git a/src/Queue/Models/QueueAccessPolicy.php b/src/Queue/Models/QueueAccessPolicy.php index f250813..ba2e927 100644 --- a/src/Queue/Models/QueueAccessPolicy.php +++ b/src/Queue/Models/QueueAccessPolicy.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; use MicrosoftAzure\Storage\Common\Models\AccessPolicy; diff --git a/src/Queue/Models/QueueMessage.php b/src/Queue/Models/QueueMessage.php index 72e4295..8da11c1 100644 --- a/src/Queue/Models/QueueMessage.php +++ b/src/Queue/Models/QueueMessage.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; use MicrosoftAzure\Storage\Common\Internal\Utilities; @@ -47,7 +47,7 @@ class QueueMessage private $dequeueCount; private $_messageText; private static $xmlRootName = 'QueueMessage'; - + /** * Creates QueueMessage object from parsed XML response of * ListMessages. @@ -61,15 +61,15 @@ class QueueMessage public static function createFromListMessages(array $parsedResponse) { $timeNextVisible = $parsedResponse['TimeNextVisible']; - + $msg = self::createFromPeekMessages($parsedResponse); $date = Utilities::rfc1123ToDateTime($timeNextVisible); $msg->setTimeNextVisible($date); $msg->setPopReceipt($parsedResponse['PopReceipt']); - + return $msg; } - + /** * Creates QueueMessage object from parsed XML response of * PeekMessages. @@ -85,18 +85,18 @@ public static function createFromPeekMessages(array $parsedResponse) $msg = new QueueMessage(); $expirationDate = $parsedResponse['ExpirationTime']; $insertionDate = $parsedResponse['InsertionTime']; - + $msg->setDequeueCount(intval($parsedResponse['DequeueCount'])); - + $date = Utilities::rfc1123ToDateTime($expirationDate); $msg->setExpirationDate($date); - + $date = Utilities::rfc1123ToDateTime($insertionDate); $msg->setInsertionDate($date); - + $msg->setMessageId($parsedResponse['MessageId']); $msg->setMessageText($parsedResponse['MessageText']); - + return $msg; } @@ -113,7 +113,7 @@ public static function createFromPeekMessages(array $parsedResponse) public static function createFromCreateMessage(array $parsedResponse) { $msg = new QueueMessage(); - + $expirationDate = $parsedResponse['ExpirationTime']; $insertionDate = $parsedResponse['InsertionTime']; $timeNextVisible = $parsedResponse['TimeNextVisible']; @@ -132,7 +132,7 @@ public static function createFromCreateMessage(array $parsedResponse) return $msg; } - + /** * Gets message text field. * @@ -142,7 +142,7 @@ public function getMessageText() { return $this->_messageText; } - + /** * Sets message text field. * @@ -154,7 +154,7 @@ public function setMessageText($messageText) { $this->_messageText = $messageText; } - + /** * Gets messageId field. * @@ -164,7 +164,7 @@ public function getMessageId() { return $this->messageId; } - + /** * Sets messageId field. * @@ -176,7 +176,7 @@ public function setMessageId($messageId) { $this->messageId = $messageId; } - + /** * Gets insertionDate field. * @@ -186,7 +186,7 @@ public function getInsertionDate() { return $this->insertionDate; } - + /** * Sets insertionDate field. * @@ -200,7 +200,7 @@ public function setInsertionDate(\DateTime $insertionDate) { $this->insertionDate = $insertionDate; } - + /** * Gets expirationDate field. * @@ -210,7 +210,7 @@ public function getExpirationDate() { return $this->expirationDate; } - + /** * Sets expirationDate field. * @@ -222,7 +222,7 @@ public function setExpirationDate(\DateTime $expirationDate) { $this->expirationDate = $expirationDate; } - + /** * Gets timeNextVisible field. * @@ -232,7 +232,7 @@ public function getTimeNextVisible() { return $this->timeNextVisible; } - + /** * Sets timeNextVisible field. * @@ -244,7 +244,7 @@ public function setTimeNextVisible($timeNextVisible) { $this->timeNextVisible = $timeNextVisible; } - + /** * Gets popReceipt field. * @@ -254,7 +254,7 @@ public function getPopReceipt() { return $this->popReceipt; } - + /** * Sets popReceipt field. * @@ -266,7 +266,7 @@ public function setPopReceipt($popReceipt) { $this->popReceipt = $popReceipt; } - + /** * Gets dequeueCount field. * @@ -276,7 +276,7 @@ public function getDequeueCount() { return $this->dequeueCount; } - + /** * Sets dequeueCount field. * @@ -290,7 +290,7 @@ public function setDequeueCount($dequeueCount) { $this->dequeueCount = $dequeueCount; } - + /** * Converts this current object to XML representation. * @@ -304,7 +304,7 @@ public function toXml(XmlSerializer $xmlSerializer) { $array = array('MessageText' => $this->_messageText); $properties = array(XmlSerializer::ROOT_NAME => self::$xmlRootName); - + return $xmlSerializer->serialize($array, $properties); } } diff --git a/src/Queue/Models/QueueServiceOptions.php b/src/Queue/Models/QueueServiceOptions.php index e85a120..737da35 100644 --- a/src/Queue/Models/QueueServiceOptions.php +++ b/src/Queue/Models/QueueServiceOptions.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; use MicrosoftAzure\Storage\Common\Models\ServiceOptions; diff --git a/src/Queue/Models/UpdateMessageResult.php b/src/Queue/Models/UpdateMessageResult.php index df53200..d4555c1 100644 --- a/src/Queue/Models/UpdateMessageResult.php +++ b/src/Queue/Models/UpdateMessageResult.php @@ -21,7 +21,7 @@ * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ - + namespace MicrosoftAzure\Storage\Queue\Models; use MicrosoftAzure\Storage\Common\Internal\Validate; @@ -78,7 +78,7 @@ public function getTimeNextVisible() { return $this->_timeNextVisible; } - + /** * Sets timeNextVisible field. * @@ -92,10 +92,10 @@ public function getTimeNextVisible() protected function setTimeNextVisible(\DateTime $timeNextVisible) { Validate::isDate($timeNextVisible); - + $this->_timeNextVisible = $timeNextVisible; } - + /** * Gets popReceipt field. * @@ -105,7 +105,7 @@ public function getPopReceipt() { return $this->_popReceipt; } - + /** * Sets popReceipt field. * diff --git a/src/Queue/QueueRestProxy.php b/src/Queue/QueueRestProxy.php index f196dd3..291373d 100644 --- a/src/Queue/QueueRestProxy.php +++ b/src/Queue/QueueRestProxy.php @@ -158,17 +158,17 @@ public function listQueuesAsync(ListQueuesOptions $options = null) $postParams = array(); $queryParams = array(); $path = Resources::EMPTY_STRING; - + if (is_null($options)) { $options = new ListQueuesOptions(); } - + $maxResults = $options->getMaxResults(); $include = $options->getIncludeMetadata(); $include = $include ? 'metadata' : null; $prefix = $options->getPrefix(); $marker = $options->getNextMarker(); - + $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'list'); $this->addOptionalQueryParam($queryParams, Resources::QP_PREFIX, $prefix); $this->addOptionalQueryParam($queryParams, Resources::QP_MARKER, $marker); @@ -180,7 +180,7 @@ public function listQueuesAsync(ListQueuesOptions $options = null) ); $dataSerializer = $this->dataSerializer; - + return $this->sendAsync( $method, $headers, @@ -240,18 +240,18 @@ public function clearMessagesAsync( ) { Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - + $method = Resources::HTTP_DELETE; $headers = array(); $postParams = array(); $queryParams = array(); $path = $queueName . '/messages'; $body = Resources::EMPTY_STRING; - + if (is_null($options)) { $options = new QueueServiceOptions(); } - + $options->setLocationMode(LocationMode::PRIMARY_ONLY); return $this->sendAsync( @@ -302,7 +302,7 @@ public function createMessageAsync( Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); Validate::canCastAsString($messageText, 'messageText'); - + $method = Resources::HTTP_POST; $headers = array(); $postParams = array(); @@ -312,21 +312,21 @@ public function createMessageAsync( $message = new QueueMessage(); $message->setMessageText($messageText); $body = $message->toXml($this->dataSerializer); - - + + if (is_null($options)) { $options = new CreateMessageOptions(); } - + $this->addOptionalHeader( $headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE ); - + $visibility = $options->getVisibilityTimeoutInSeconds(); $timeToLive = $options->getTimeToLiveInSeconds(); - + $this->addOptionalQueryParam( $queryParams, Resources::QP_VISIBILITY_TIMEOUT, @@ -337,7 +337,7 @@ public function createMessageAsync( Resources::QP_MESSAGE_TTL, $timeToLive ); - + $options->setLocationMode(LocationMode::PRIMARY_ONLY); $dataSerializer = $this->dataSerializer; @@ -386,20 +386,20 @@ public function createQueueAsync( ) { Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - + $method = Resources::HTTP_PUT; $headers = array(); $postParams = array(); $queryParams = array(); $path = $queueName; - + if (is_null($options)) { $options = new CreateQueueOptions(); } $metadata = $options->getMetadata(); $headers = $this->generateMetadataHeaders($metadata); - + $options->setLocationMode(LocationMode::PRIMARY_ONLY); return $this->sendAsync( @@ -462,24 +462,24 @@ public function deleteMessageAsync( Validate::notNullOrEmpty($messageId, 'messageId'); Validate::canCastAsString($popReceipt, 'popReceipt'); Validate::notNullOrEmpty($popReceipt, 'popReceipt'); - + $method = Resources::HTTP_DELETE; $headers = array(); $postParams = array(); $queryParams = array(); $path = $queueName . '/messages/' . $messageId; $body = Resources::EMPTY_STRING; - + if (is_null($options)) { $options = new QueueServiceOptions(); } - + $this->addOptionalQueryParam( $queryParams, Resources::QP_POPRECEIPT, $popReceipt ); - + $options->setLocationMode(LocationMode::PRIMARY_ONLY); return $this->sendAsync( @@ -521,17 +521,17 @@ public function deleteQueueAsync( ) { Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - + $method = Resources::HTTP_DELETE; $headers = array(); $postParams = array(); $queryParams = array(); $path = $queueName; - + if (is_null($options)) { $options = new QueueServiceOptions(); } - + $options->setLocationMode(LocationMode::PRIMARY_ONLY); return $this->sendAsync( @@ -573,20 +573,20 @@ public function getQueueMetadataAsync( ) { Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - + $method = Resources::HTTP_GET; $headers = array(); $postParams = array(); $queryParams = array(); $path = $queueName; $body = Resources::EMPTY_STRING; - + if (is_null($options)) { $options = new QueueServiceOptions(); } - + $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'metadata'); - + return $this->sendAsync( $method, $headers, @@ -605,7 +605,7 @@ public function getQueueMetadataAsync( Resources::X_MS_APPROXIMATE_MESSAGES_COUNT ) ); - + return new GetQueueMetadataResult($maxCount, $metadata); }, null); } @@ -637,20 +637,20 @@ public function listMessagesAsync( ) { Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - + $method = Resources::HTTP_GET; $headers = array(); $queryParams = array(); $postParams = array(); $path = $queueName . '/messages'; - + if (is_null($options)) { $options = new ListMessagesOptions(); } - + $messagesCount = $options->getNumberOfMessages(); $visibility = $options->getVisibilityTimeoutInSeconds(); - + $this->addOptionalQueryParam( $queryParams, Resources::QP_NUM_OF_MESSAGES, @@ -663,7 +663,7 @@ public function listMessagesAsync( ); $dataSerializer = $this->dataSerializer; - + $options->setLocationMode(LocationMode::PRIMARY_ONLY); return $this->sendAsync( @@ -710,26 +710,26 @@ public function peekMessagesAsync( ) { Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - + $method = Resources::HTTP_GET; $headers = array(); $queryParams = array(); $postParams = array(); $path = $queueName . '/messages'; - + if (is_null($options)) { $options = new PeekMessagesOptions(); } - + $messagesCount = $options->getNumberOfMessages(); - + $this->addOptionalQueryParam($queryParams, Resources::QP_PEEK_ONLY, 'true'); $this->addOptionalQueryParam( $queryParams, Resources::QP_NUM_OF_MESSAGES, $messagesCount ); - + $dataSerializer = $this->dataSerializer; return $this->sendAsync( @@ -783,23 +783,23 @@ public function setQueueMetadataAsync( Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); Utilities::validateMetadata($metadata); - + $method = Resources::HTTP_PUT; $headers = array(); $queryParams = array(); $postParams = array(); $path = $queueName; $body = Resources::EMPTY_STRING; - + if (is_null($options)) { $options = new QueueServiceOptions(); } - + $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'metadata'); - + $metadataHeaders = $this->generateMetadataHeaders($metadata); $headers = $metadataHeaders; - + $options->setLocationMode(LocationMode::PRIMARY_ONLY); return $this->sendAsync( @@ -896,18 +896,18 @@ public function updateMessageAsync( $visibilityTimeoutInSeconds, 'visibilityTimeoutInSeconds' ); - + $method = Resources::HTTP_PUT; $headers = array(); $postParams = array(); $queryParams = array(); $path = $queueName . '/messages' . '/' . $messageId; $body = Resources::EMPTY_STRING; - + if (is_null($options)) { $options = new QueueServiceOptions(); } - + $this->addOptionalQueryParam( $queryParams, Resources::QP_VISIBILITY_TIMEOUT, @@ -918,19 +918,19 @@ public function updateMessageAsync( Resources::QP_POPRECEIPT, $popReceipt ); - + if (!empty($messageText)) { $this->addOptionalHeader( $headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE ); - + $message = new QueueMessage(); $message->setMessageText($messageText); $body = $message->toXml($this->dataSerializer); } - + $options->setLocationMode(LocationMode::PRIMARY_ONLY); return $this->sendAsync( @@ -980,18 +980,18 @@ public function getQueueAclAsync( Models\QueueServiceOptions $options = null ) { Validate::canCastAsString($queue, 'queue'); - + $method = Resources::HTTP_GET; $headers = array(); $postParams = array(); $queryParams = array(); $statusCode = Resources::STATUS_OK; $path = $queue; - + if (is_null($options)) { $options = new QueueServiceOptions(); } - + $this->addOptionalQueryParam( $queryParams, Resources::QP_COMP, @@ -999,7 +999,7 @@ public function getQueueAclAsync( ); $dataSerializer = $this->dataSerializer; - + $promise = $this->sendAsync( $method, $headers, @@ -1016,7 +1016,7 @@ public function getQueueAclAsync( return QueueACL::create($parsed); }, null); } - + /** * Sets the ACL. * @@ -1054,18 +1054,18 @@ public function setQueueAclAsync( ) { Validate::canCastAsString($queue, 'queue'); Validate::notNullOrEmpty($acl, 'acl'); - + $method = Resources::HTTP_PUT; $headers = array(); $postParams = array(); $queryParams = array(); $body = $acl->toXml($this->dataSerializer); $path = $queue; - + if (is_null($options)) { $options = new QueueServiceOptions(); } - + $this->addOptionalQueryParam( $queryParams, Resources::QP_COMP, @@ -1073,7 +1073,7 @@ public function setQueueAclAsync( ); $options->setLocationMode(LocationMode::PRIMARY_ONLY); - + return $this->sendAsync( $method, $headers,