/** * Returns a link to a element source code. * * @param \ApiGen\Reflection\ReflectionElement $element Element reflection * @param boolean $withLine Include file line number into the link * @return string */ public function getSourceUrl(Reflection\ReflectionElement $element, $withLine = true) { if ($element instanceof Reflection\ReflectionClass || $element instanceof Reflection\ReflectionFunction || $element instanceof Reflection\ReflectionConstant && null === $element->getDeclaringClassName()) { $elementName = $element->getName(); if ($element instanceof Reflection\ReflectionClass) { $file = 'class-'; } elseif ($element instanceof Reflection\ReflectionConstant) { $file = 'constant-'; } elseif ($element instanceof Reflection\ReflectionFunction) { $file = 'function-'; } } else { $elementName = $element->getDeclaringClassName(); $file = 'class-'; } $file .= $this->urlize($elementName); $lines = null; if ($withLine) { $lines = $element->getStartLine() !== $element->getEndLine() ? sprintf('%s-%s', $element->getStartLine(), $element->getEndLine()) : $element->getStartLine(); } return sprintf($this->config->template->templates->main->source->filename, $file) . (null !== $lines ? '#' . $lines : ''); }
/** * @param ReflectionMethod|ReflectionProperty $reflection * @return string */ private function getPropertyOrMethodFqnName(ReflectionElement $reflection) { return $reflection->getDeclaringClassName() . '::' . $reflection->getName(); }
/** * @return string */ private function getElementName(ReflectionElement $element) { return strtolower(strtr(ltrim($element->getName(), '_'), '_', '-')); }