1: <?php
2:
3: /*
4: * This file is part of SwiftMailer.
5: * (c) 2004-2009 Chris Corbyn
6: *
7: * For the full copyright and license information, please view the LICENSE
8: * file that was distributed with this source code.
9: */
10:
11: /**
12: * Wraps a standard PHP array in an interator.
13: * @package Swift
14: * @subpackage Mailer
15: * @author Chris Corbyn
16: */
17: class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientIterator
18: {
19: /**
20: * The list of recipients.
21: * @var array
22: * @access private
23: */
24: private $_recipients = array();
25:
26: /**
27: * Create a new ArrayRecipientIterator from $recipients.
28: * @param array $recipients
29: */
30: public function __construct(array $recipients)
31: {
32: $this->_recipients = $recipients;
33: }
34:
35: /**
36: * Returns true only if there are more recipients to send to.
37: * @return boolean
38: */
39: public function hasNext()
40: {
41: return !empty($this->_recipients);
42: }
43:
44: /**
45: * Returns an array where the keys are the addresses of recipients and the
46: * values are the names.
47: * e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL)
48: * @return array
49: */
50: public function nextRecipient()
51: {
52: return array_splice($this->_recipients, 0, 1);
53: }
54: }
55: