Added feature #15998: Create a new API to send mails based on SwiftMailer to replace...
[Packages/TYPO3.CMS.git] / typo3 / contrib / swiftmailer / classes / Swift / Mailer / ArrayRecipientIterator.php
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 //@require 'Swift/Mailer/RecipientIterator.php';
12
13 /**
14 * Wraps a standard PHP array in an interator.
15 * @package Swift
16 * @subpackage Mailer
17 * @author Chris Corbyn
18 */
19 class Swift_Mailer_ArrayRecipientIterator
20 implements Swift_Mailer_RecipientIterator
21 {
22
23 /**
24 * The list of recipients.
25 * @var array
26 * @access private
27 */
28 private $_recipients = array();
29
30 /**
31 * Create a new ArrayRecipientIterator from $recipients.
32 * @param array $recipients
33 */
34 public function __construct(array $recipients)
35 {
36 $this->_recipients = $recipients;
37 }
38
39 /**
40 * Returns true only if there are more recipients to send to.
41 * @return boolean
42 */
43 public function hasNext()
44 {
45 return !empty($this->_recipients);
46 }
47
48 /**
49 * Returns an array where the keys are the addresses of recipients and the
50 * values are the names.
51 * e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL)
52 * @return array
53 */
54 public function nextRecipient()
55 {
56 return array_splice($this->_recipients, 0, 1);
57 }
58
59 }