TYPO3 API  SVNRelease
ArrayRecipientIterator.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of SwiftMailer.
00005  * (c) 2004-2009 Chris Corbyn
00006  *
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
00009  */
00010 
00011 //@require 'Swift/Mailer/RecipientIterator.php';
00012 
00013 /**
00014  * Wraps a standard PHP array in an interator.
00015  * @package Swift
00016  * @subpackage Mailer
00017  * @author Chris Corbyn
00018  */
00019 class Swift_Mailer_ArrayRecipientIterator
00020   implements Swift_Mailer_RecipientIterator
00021 {
00022 
00023   /**
00024    * The list of recipients.
00025    * @var array
00026    * @access private
00027    */
00028   private $_recipients = array();
00029 
00030   /**
00031    * Create a new ArrayRecipientIterator from $recipients.
00032    * @param array $recipients
00033    */
00034   public function __construct(array $recipients)
00035   {
00036     $this->_recipients = $recipients;
00037   }
00038 
00039   /**
00040    * Returns true only if there are more recipients to send to.
00041    * @return boolean
00042    */
00043   public function hasNext()
00044   {
00045     return !empty($this->_recipients);
00046   }
00047 
00048   /**
00049    * Returns an array where the keys are the addresses of recipients and the
00050    * values are the names.
00051    * e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL)
00052    * @return array
00053    */
00054   public function nextRecipient()
00055   {
00056     return array_splice($this->_recipients, 0, 1);
00057   }
00058 
00059 }