| Server IP : 172.67.71.254 / Your IP : 216.73.216.4 Web Server : nginx/1.27.1 System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : arabianexpress ( 1872) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /storage/v9321/leapdubai/public_html/wp-content/plugins/kirki/libraries/framework/ |
Upload File : |
<?php
/**
* Abstract base for static facades that proxy calls to container-resolved services.
* Caches resolved instances per accessor and forwards __callStatic to the underlying object.
* Enables Facade::method() syntax throughout the framework.
*
* @package Framework
* @since 1.0.0
*/
namespace Kirki\Framework;
\defined('ABSPATH') || exit;
use RuntimeException;
use function Kirki\Framework\app;
abstract class Facade
{
/**
* The array of resolved service instances keyed by accessor name.
*
* @var array
*
* @since 1.0.0
*/
protected static $resolved_instance = [];
/**
* Whether the facade is cacheable.
*
* @var bool
*
* @since 1.0.0
*/
protected static $is_cacheable = \true;
/**
* Get the accessor key for the service in the container.
*
* Child classes must implement this method to return the string accessor
* used to resolve the service from the application container.
*
* @return string
*
* @since 1.0.0
*/
public static abstract function get_accessor();
/**
* Resolve the underlying service instance for the given accessor name.
*
* If the name is already an object, it is returned directly. Otherwise,
* the service is resolved from the application container and cached.
*
* @param string|object $name The accessor name or an object instance
*
* @return object The resolved service instance
*
* @since 1.0.0
*/
protected static function resolved_facade_instance($name)
{
if (\is_object($name)) {
return $name;
}
if (static::$is_cacheable && isset(static::$resolved_instance[$name])) {
return static::$resolved_instance[$name];
}
$instance = app($name);
if (static::$is_cacheable) {
static::$resolved_instance[$name] = $instance;
}
return $instance;
}
/**
* Dynamically handle static method calls to the facade.
*
* Forwards the static call to the resolved service instance, passing all arguments.
* Throws a RuntimeException if the service instance cannot be resolved.
*
* @param string $method The method name being called
* @param array $arguments The arguments passed to the method
*
* @return mixed The result of the underlying method call
*
* @throws \RuntimeException
*
* @since 1.0.0
*/
public static function __callStatic($method, $arguments)
{
$instance = static::resolved_facade_instance(static::get_accessor());
if (!$instance) {
throw new RuntimeException('A facade has not been set.');
}
return $instance->{$method}(...$arguments);
}
}