You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
857 B

<?php
/**
* Created by PhpStorm.
* User: Admin
* Date: 2018/12/24
* Time: 18:33
*/
namespace app\lib\facade;
class Facade
{
public static function getInstance($className,$option){
return new $className($option);
}
/**
* 待子类重写,用于获取代理对象
*/
public static function getFacadeAccessor(){
}
/**
* @return mixed
* 获取构造函数参数
*/
public static function getConstructParam(){
return [];
}
public static function __callStatic($functionName,$arguments)
{
$instance = static::getInstance(static::getFacadeAccessor(),static::getConstructParam());//获取代理对象
return call_user_func_array([$instance,$functionName],$arguments);//调用代理对象内的$name方法,并传入$arguments作为参数
}
}