private function buildDocument($reflector)
{
$name = $reflector->getShortName();
$id = substr($reflector->getName(), 14);
$id = str_replace('\\', '/', $id);
// @todo see if there is a better way to determine the type
$parts = explode('_', get_class($reflector->getNode()));
$type = end($parts);
$docBlock = $reflector->getDocBlock();
$magic = [];
if ($docBlock && $docBlock->getTags()) {
$magicMethods = array_filter($docBlock->getTags(), function ($tag) {
return $tag->getName() === 'method';
});
$magic = $this->buildMagicMethods($magicMethods, $name);
}
$methods = $reflector->getMethods();
if (is_null($docBlock)) {
throw new \Exception(sprintf('%s has no description', $reflector->getName()));
}
$split = $this->splitDescription($docBlock->getText());
return ['id' => strtolower($id), 'type' => strtolower($type), 'title' => $reflector->getNamespace() . '\\' . $name, 'name' => $name, 'description' => $this->buildDescription($docBlock, $split['description']), 'examples' => $this->buildExamples($split['examples']), 'resources' => $this->buildResources($docBlock->getTagsByName('see')), 'methods' => array_merge($this->buildMethods($methods, $name), $magic)];
}