From 6130ea30c5d3e38c1b4125e936bdbc1ae808ea9c Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 13 Jun 2023 21:08:55 +0200 Subject: [PATCH] Add separate signature anchor method --- src/PhpDoc/MethodDoc.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/PhpDoc/MethodDoc.php b/src/PhpDoc/MethodDoc.php index 9b649fa..ab57db2 100644 --- a/src/PhpDoc/MethodDoc.php +++ b/src/PhpDoc/MethodDoc.php @@ -122,13 +122,24 @@ class MethodDoc extends GenericDoc * @return string */ public function getSignatureLink(): string + { + $sig = $this->getSignature(); + $sigLink = $this->getSignatureAnchor(); + return "[`$sig`](#$sigLink)"; + } + /** + * Get method signature link. + * + * @return string + */ + public function getSignatureAnchor(): string { $sig = $this->getSignature(); $sigLink = strtolower($sig); $sigLink = preg_replace('/[^\w ]+/', ' ', $sigLink); $sigLink = preg_replace('/ +/', ' ', $sigLink); $sigLink = str_replace(' ', '-', $sigLink); - return "[`$sig`](#$sigLink)"; + return $sigLink; } /** * Generate markdown for method.