Skip to content
This repository
Browse code

getMessage return value fixed

  • Loading branch information...
commit 91cdbaa219701c780246156c1e03ee665011677e 1 parent d17adfe
Alexander Shapiotko authored April 20, 2012

Showing 1 changed file with 21 additions and 3 deletions. Show diff stats Hide diff stats

  1. 24  IronMQ.class.php
24  IronMQ.class.php
@@ -6,7 +6,7 @@
6 6
  * @link https://github.com/iron-io/iron_mq_php
7 7
  * @link http://www.iron.io/products/mq
8 8
  * @link http://dev.iron.io/
9  
- * @version 1.0
  9
+ * @version 1.0.1
10 10
  * @package IronMQPHP
11 11
  * @copyright Feel free to copy, steal, take credit for, or whatever you feel like doing with this code. ;)
12 12
  */
@@ -312,6 +312,13 @@ public function postMessages($queue_name, $messages) {
312 312
         return self::json_decode($res);
313 313
     }
314 314
 
  315
+    /**
  316
+     * Get multiplie messages from queue
  317
+     *
  318
+     * @param string $queue_name Queue name
  319
+     * @param int $count
  320
+     * @return array|null array of messages or null
  321
+     */
315 322
     public function getMessages($queue_name, $count=1) {
316 323
         $url = "projects/{$this->project_id}/queues/{$queue_name}/messages";
317 324
         $params = array();
@@ -324,12 +331,23 @@ public function getMessages($queue_name, $count=1) {
324 331
         if(count($result->messages) < 1) {
325 332
             return null;
326 333
         } else {
327  
-            return $result;
  334
+            return $result->messages;
328 335
         }
329 336
     }
330 337
 
  338
+    /**
  339
+     * Get single message from queue
  340
+     *
  341
+     * @param string $queue_name Queue name
  342
+     * @return mixed|null single message or null
  343
+     */
331 344
     public function getMessage($queue_name) {
332  
-        return $this->getMessages($queue_name, 1);
  345
+        $messages = $this->getMessages($queue_name, 1);
  346
+        if ($messages){
  347
+            return $messages[0];
  348
+        }else{
  349
+            return null;
  350
+        }
333 351
     }
334 352
 
335 353
     public function deleteMessage($queue_name, $message_id) {

0 notes on commit 91cdbaa

Please sign in to comment.
Something went wrong with that request. Please try again.