HitReporter.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * A reporter which "collects" failures for the Reporter plugin.
  11. *
  12. * @author Chris Corbyn
  13. */
  14. class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
  15. {
  16. /**
  17. * The list of failures.
  18. *
  19. * @var array
  20. */
  21. private $_failures = array();
  22. private $_failures_cache = array();
  23. /**
  24. * Notifies this ReportNotifier that $address failed or succeeded.
  25. *
  26. * @param Swift_Mime_Message $message
  27. * @param string $address
  28. * @param int $result from {@link RESULT_PASS, RESULT_FAIL}
  29. */
  30. public function notify(Swift_Mime_Message $message, $address, $result)
  31. {
  32. if (self::RESULT_FAIL == $result && !isset($this->_failures_cache[$address])) {
  33. $this->_failures[] = $address;
  34. $this->_failures_cache[$address] = true;
  35. }
  36. }
  37. /**
  38. * Get an array of addresses for which delivery failed.
  39. *
  40. * @return array
  41. */
  42. public function getFailedRecipients()
  43. {
  44. return $this->_failures;
  45. }
  46. /**
  47. * Clear the buffer (empty the list).
  48. */
  49. public function clear()
  50. {
  51. $this->_failures = $this->_failures_cache = array();
  52. }
  53. }