HEX
Server: nginx/1.27.1
System: Linux in-3 5.15.0-161-generic #171-Ubuntu SMP Sat Oct 11 08:17:01 UTC 2025 x86_64
User: ivenus-clone (3297)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v4513/ivenusnew/public_html/wp-content/plugins/sg-cachepress/core/Helper/Factory_Trait.php
<?php
namespace SiteGround_Optimizer\Helper;

use SiteGround_i18n\i18n_Service;
/**
 * Trait used for factory pattern in the plugin.
 */
trait Factory_Trait {

	/**
	 * Create a new dependency.
	 *
	 * @since 5.9.0
	 *
	 * @param string $namespace  The namespace of the dependency.
	 * @param string $class The type of the dependency.
	 *
	 * @throws \Exception Exception If the type is not supported.
	 */
	public function factory( $namespace, $class ) {
		// Build the type and path for the dependency.
		$type = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $class ) ) );
		$path = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $namespace ) ) );

		$class_path = 'SiteGround_Optimizer\\' . $path . '\\' . $type;

		if ( ! class_exists( $class_path ) ) {
			throw new \Exception( 'Unknown dependency type "' . esc_html( $type ) . '" in "' . esc_html( $path ) . '".' );
		}

		// Define the class.
		$this->$class = new $class_path();
	}
}