改名
This commit is contained in:
+29
-3
@@ -2,19 +2,45 @@
|
||||
|
||||
namespace Kiri\Rpc;
|
||||
|
||||
use Kiri\Kiri;
|
||||
use ReflectionException;
|
||||
|
||||
class RpcManager
|
||||
{
|
||||
|
||||
private static array $_rpc = [];
|
||||
|
||||
public static function add()
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $class
|
||||
* @return bool
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function add(string $name, string $class): bool
|
||||
{
|
||||
$methods = Kiri::getDi()->getReflect($class);
|
||||
$lists = $methods->getMethods(\ReflectionMethod::IS_PUBLIC);
|
||||
|
||||
if (!isset(static::$_rpc[$name])) static::$_rpc[$name] = [];
|
||||
|
||||
foreach ($lists as $reflection) {
|
||||
$params = Kiri::getDi()->getMethodParameters($class, $reflection->getName());
|
||||
|
||||
static::$_rpc[$name][] = [$reflection->getName(), $params];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function get()
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $method
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get(string $name, string $method): array
|
||||
{
|
||||
|
||||
return static::$_rpc[$name][$method] ?? [null, null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user