2019-01-05 03:25:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace JsonRpc\Server;
|
|
|
|
|
2019-01-14 07:30:04 +00:00
|
|
|
use itxq\apidoc\BootstrapApiDoc;
|
|
|
|
|
2019-01-05 03:25:30 +00:00
|
|
|
class JsonRpcDoc
|
|
|
|
{
|
|
|
|
|
2019-01-07 07:32:24 +00:00
|
|
|
protected $config;
|
2019-01-05 03:25:30 +00:00
|
|
|
|
2019-01-07 07:32:24 +00:00
|
|
|
protected $classes;
|
|
|
|
|
|
|
|
public function __construct($config)
|
2019-01-05 03:25:30 +00:00
|
|
|
{
|
2019-01-07 07:32:24 +00:00
|
|
|
$this->map = include $config['map'];
|
2019-01-05 03:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function methods()
|
|
|
|
{
|
2019-01-07 07:32:24 +00:00
|
|
|
$methods = [];
|
|
|
|
foreach ($this->map as $key => $item) {
|
2019-01-14 07:30:04 +00:00
|
|
|
if (!in_array($item[0], $methods)) {
|
|
|
|
$methods[] = $item[0];
|
|
|
|
}
|
2019-01-07 07:32:24 +00:00
|
|
|
}
|
|
|
|
return $methods;
|
2019-01-05 03:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
2019-01-14 08:54:06 +00:00
|
|
|
// /**
|
|
|
|
// * @var $view Factory
|
|
|
|
// */
|
|
|
|
// $config = [
|
|
|
|
// 'class' => $this->methods(),
|
|
|
|
// 'filter_method' => [],
|
|
|
|
// ];
|
|
|
|
// $api = new BootstrapApiDoc($config);
|
|
|
|
// $doc = $api->getHtml();
|
|
|
|
// exit($doc);
|
|
|
|
return view()->file(__DIR__."/../Sami/document/index.html");
|
2019-01-07 07:32:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function desc($class, $method)
|
|
|
|
{
|
|
|
|
if (!isset($this->classes[$class])) {
|
|
|
|
$reflector = new \ReflectionClass($class);
|
|
|
|
$this->classes[$class] = $reflector;
|
|
|
|
} else {
|
|
|
|
$reflector = $this->classes[$class];
|
|
|
|
}
|
|
|
|
|
|
|
|
return str_replace("/**\n",'',$reflector->getMethod($method)->getDocComment());
|
2019-01-05 03:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|