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