HEX
Server: nginx/1.26.1
System: Linux main-vm 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
User: root (0)
PHP: 8.2.19
Disabled: NONE
Upload Files
File: /var/www/chameleon/wp-content/plugins/suremails/inc/emails/handler/connection-handler-factory.php
<?php
/**
 * Connection Handler Factory
 *
 * @since 0.0.1
 * @package suremails
 */

namespace SureMails\Inc\Emails\Handler;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Factory class to create appropriate connection handler based on type.
 */
class ConnectionHandlerFactory {
	/**
	 * Create appropriate connection handler based on type.
	 *
	 * @param array $connection_data Connection data.
	 * @since 0.0.1
	 * @return ConnectionHandler|null
	 */
	public static function create( array $connection_data ) {
		$handler_class = 'SureMails\\Inc\\Emails\\Providers\\' . strtoupper( $connection_data['type'] ) . '\\' . ucfirst( strtolower( $connection_data['type'] ) ) . 'Handler';

		if ( class_exists( $handler_class ) ) {
			$handler = new $handler_class( $connection_data );

			// Ensure the handler implements ConnectionHandler.
			if ( $handler instanceof ConnectionHandler ) {
				return $handler;
			}
		}

		return null;
	}
}