Skip to content

Commit 6e5eabc

Browse files
committed
Generators/HTML::getFormattedToc(): minor simplification
Use `sprintf()` on a template string.
1 parent 8f9f5d2 commit 6e5eabc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Generators/HTML.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,14 @@ protected function getFormattedToc()
202202
$output = ' <h2>Table of Contents</h2>'.PHP_EOL;
203203
$output .= ' <ul class="toc">'.PHP_EOL;
204204

205+
$listItemTemplate = ' <li><a href="#%s">%s</a></li>'.PHP_EOL;
206+
205207
foreach ($this->docFiles as $file) {
206208
$doc = new DOMDocument();
207209
$doc->load($file);
208210
$documentation = $doc->getElementsByTagName('documentation')->item(0);
209211
$title = $this->getTitle($documentation);
210-
$output .= ' <li><a href="#'.str_replace(' ', '-', $title).'">'.$title.'</a></li>'.PHP_EOL;
212+
$output .= sprintf($listItemTemplate, str_replace(' ', '-', $title), $title);
211213
}
212214

213215
$output .= ' </ul>'.PHP_EOL;

0 commit comments

Comments
 (0)