HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //var/www/html/TriadGov/wp-content/plugins/wp-mail-smtp-pro/src/Pro/Alerts/Notifier.php
<?php

namespace WPMailSMTP\Pro\Alerts;

use WPMailSMTP\Pro\Alerts\Handlers\HandlerInterface;

/**
 * Class Notifier.
 *
 * @since 3.5.0
 */
class Notifier {

	/**
	 * Registered handlers.
	 *
	 * @since 3.5.0
	 *
	 * @var HandlerInterface[]
	 */
	private $handlers = [];

	/**
	 * Register handler.
	 *
	 * @since 3.5.0
	 *
	 * @param HandlerInterface $handler Handler object.
	 */
	public function push_handler( HandlerInterface $handler ) {

		$this->handlers[] = $handler;
	}

	/**
	 * Send notification via registered handlers.
	 *
	 * @since 3.5.0
	 *
	 * @param Alert $alert Alert object.
	 */
	public function notify( Alert $alert ) {

		foreach ( $this->handlers as $handler ) {
			if ( ! $handler->can_handle( $alert ) ) {
				continue;
			}

			$handler->handle( $alert );
		}
	}
}