This commit is contained in:
2021-10-28 15:14:21 +08:00
parent 791af89ba9
commit 7e91e227b2
4 changed files with 47 additions and 30 deletions
+29 -3
View File
@@ -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];
}
}