MessageSet.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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-2015 Zend Technologies USA Inc. (http://www.zend.com)
  17. * @license http://framework.zend.com/license/new-bsd New BSD License
  18. */
  19. /**
  20. * Collection of message objects
  21. *
  22. * @category Zend
  23. * @package Zend_Cloud
  24. * @subpackage QueueService
  25. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  26. * @license http://framework.zend.com/license/new-bsd New BSD License
  27. */
  28. class Zend_Cloud_QueueService_MessageSet implements Countable, IteratorAggregate
  29. {
  30. /** @var int */
  31. protected $_messageCount;
  32. /** @var ArrayAccess Messages */
  33. protected $_messages;
  34. /**
  35. * Constructor
  36. *
  37. * @param array $messages
  38. * @return void
  39. */
  40. public function __construct(array $messages)
  41. {
  42. $this->_messageCount = count($messages);
  43. $this->_messages = new ArrayIterator($messages);
  44. }
  45. /**
  46. * Countable: number of messages in collection
  47. *
  48. * @return int
  49. */
  50. public function count()
  51. {
  52. return $this->_messageCount;
  53. }
  54. /**
  55. * IteratorAggregate: return iterable object
  56. *
  57. * @return Traversable
  58. */
  59. public function getIterator()
  60. {
  61. return $this->_messages;
  62. }
  63. }