Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

67 lines (57 sloc) 1.8 kB
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* @namespace
*/
namespace Zend\Mail;
/**
* Collection of recipients
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class AddressCollection {
protected $addresses = array();
public function add(Address $address) {
$filtered = $address->getEmail(true);
if(isset($this->_recipients[$filtered])) {
throw new Exception\OutOfBoundsException(
"An address with email address '".$filtered."' was added already"
. 'and can be added only once'
);
}
$this->addresses[$filtered] = $address;
}
public function getAddresses() {
return $this->addresses;
}
public function getEmailAddresses() {
return array_keys($this->addresses);
}
public function __toString() {
$out = reset($this->addresses);
if(!$out) {
return '';
}
return (string) $out;
}
}
Jump to Line
Something went wrong with that request. Please try again.