function testRemoveEmailAddress() { $this->assertIdentical(StringUtility::removeEmailAddress('*****@*****.**', true), ''); $this->assertIdentical(StringUtility::removeEmailAddress('*****@*****.**', false), ''); $this->assertIdentical(StringUtility::removeEmailAddress('Will Buckner wcc@nospammonkeys.org', true), 'Will Buckner'); $this->assertIdentical(StringUtility::removeEmailAddress('Will Buckner wcc@nospammonkeys.org', false), 'Will Buckner '); $this->assertIdentical(StringUtility::removeEmailAddress('Will Buckner wcc@nospammonkeys.org 770.223.0123 ', true), 'Will Buckner 770.223.0123'); $this->assertIdentical(StringUtility::removeEmailAddress('Will Buckner wcc@nospammonkeys.org 770.223.0123 ', false), 'Will Buckner 770.223.0123 '); $this->assertNotIdentical(StringUtility::removeEmailAddress('wcc@nospammonkeys.org ', false), ''); $this->assertNotIdentical(StringUtility::removeEmailAddress(' wcc@nospammonkeys.org ', true), ' '); }
protected function _extractEmailAddress() { foreach ($this->_addressBlock as $lineNumber => $line) { if (!StringUtility::containsEmailAddress($line)) { continue; } /* Extract and properly format the e-mail address. */ $emailAddress = StringUtility::extractEmailAddress($line); /* If there is more on this line, remove the e-mail address from * the line. Otherwise, just delete the line. */ if (!StringUtility::isEmailAddress($line)) { $line = StringUtility::removeEmailAddress($line, true); $this->_addressBlock[$lineNumber] = $line; } else { unset($this->_addressBlock[$lineNumber]); $this->_addressBlock = array_merge($this->_addressBlock); } return $emailAddress; } return ''; }