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: * A reporter which "collects" failures for the Reporter plugin.
13: * @package Swift
14: * @subpackage Plugins
15: * @author Chris Corbyn
16: */
17: class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
18: {
19: /**
20: * The list of failures.
21: * @var array
22: * @access private
23: */
24: private $_failures = array();
25: private $_failures_cache = array();
26:
27: /**
28: * Notifies this ReportNotifier that $address failed or succeeded.
29: * @param Swift_Mime_Message $message
30: * @param string $address
31: * @param int $result from {@link RESULT_PASS, RESULT_FAIL}
32: */
33: public function notify(Swift_Mime_Message $message, $address, $result)
34: {
35: if (self::RESULT_FAIL == $result && !isset($this->_failures_cache[$address])) {
36: $this->_failures[] = $address;
37: $this->_failures_cache[$address] = true;
38: }
39: }
40:
41: /**
42: * Get an array of addresses for which delivery failed.
43: * @return array
44: */
45: public function getFailedRecipients()
46: {
47: return $this->_failures;
48: }
49:
50: /**
51: * Clear the buffer (empty the list).
52: */
53: public function clear()
54: {
55: $this->_failures = $this->_failures_cache = array();
56: }
57: }
58: