| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/INFRABIKEDE/wp-content/plugins/sg-cachepress/core/Helper/ |
Upload File : |
<?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 "' . $type . '" in "' . $path . '".' );
}
// Define the class.
$this->$class = new $class_path();
}
}