|
1 <?php |
|
2 /** |
|
3 * LICENSE |
|
4 * |
|
5 * This source file is subject to the new BSD license that is bundled |
|
6 * with this package in the file LICENSE.txt. |
|
7 * It is also available through the world-wide-web at this URL: |
|
8 * http://framework.zend.com/license/new-bsd |
|
9 * If you did not receive a copy of the license and are unable to |
|
10 * obtain it through the world-wide-web, please send an email |
|
11 * to license@zend.com so we can send you a copy immediately. |
|
12 * |
|
13 * @category Zend |
|
14 * @package Zend_Cloud |
|
15 * @subpackage QueueService |
|
16 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
17 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
18 */ |
|
19 |
|
20 /** |
|
21 * Collection of message objects |
|
22 * |
|
23 * @category Zend |
|
24 * @package Zend_Cloud |
|
25 * @subpackage QueueService |
|
26 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
27 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
28 */ |
|
29 class Zend_Cloud_QueueService_MessageSet implements Countable, IteratorAggregate |
|
30 { |
|
31 /** @var int */ |
|
32 protected $_messageCount; |
|
33 |
|
34 /** @var ArrayAccess Messages */ |
|
35 protected $_messages; |
|
36 |
|
37 /** |
|
38 * Constructor |
|
39 * |
|
40 * @param array $messages |
|
41 * @return void |
|
42 */ |
|
43 public function __construct(array $messages) |
|
44 { |
|
45 $this->_messageCount = count($messages); |
|
46 $this->_messages = new ArrayIterator($messages); |
|
47 } |
|
48 |
|
49 /** |
|
50 * Countable: number of messages in collection |
|
51 * |
|
52 * @return int |
|
53 */ |
|
54 public function count() |
|
55 { |
|
56 return $this->_messageCount; |
|
57 } |
|
58 |
|
59 /** |
|
60 * IteratorAggregate: return iterable object |
|
61 * |
|
62 * @return Traversable |
|
63 */ |
|
64 public function getIterator() |
|
65 { |
|
66 return $this->_messages; |
|
67 } |
|
68 } |