Skip to content

Commit 8f9f5d2

Browse files
committed
Generators/HTML::getFormattedFooter(): minor simplification
Use a single call to `sprintf()` instead of lots of string concatenation.
1 parent 84d0a5f commit 8f9f5d2

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/Generators/HTML.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,17 @@ protected function getFormattedFooter()
245245
// Turn off errors so we don't get timezone warnings if people
246246
// don't have their timezone set.
247247
$errorLevel = error_reporting(0);
248-
$output = ' <div class="tag-line">';
249-
$output .= 'Documentation generated on '.date('r');
250-
$output .= ' by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer '.Config::VERSION.'</a>';
251-
$output .= '</div>'.PHP_EOL;
248+
$output = sprintf(
249+
' <div class="tag-line">Documentation generated on %s by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer %s</a></div>
250+
</body>
251+
</html>',
252+
date('r'),
253+
Config::VERSION
254+
);
252255
error_reporting($errorLevel);
253256

254-
$output .= ' </body>'.PHP_EOL;
255-
$output .= '</html>'.PHP_EOL;
256-
257-
return $output;
257+
// Use the correct line endings based on the OS.
258+
return str_replace("\n", PHP_EOL, $output).PHP_EOL;
258259

259260
}//end getFormattedFooter()
260261

tests/Core/Generators/Fixtures/HTMLDouble.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ class HTMLDouble extends HTML
2020
*/
2121
protected function getFormattedFooter()
2222
{
23-
$output = ' <div class="tag-line">';
24-
$output .= 'Documentation generated on #REDACTED#';
25-
$output .= ' by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer #VERSION#</a>';
26-
$output .= '</div>'.PHP_EOL;
27-
$output .= ' </body>'.PHP_EOL;
28-
$output .= '</html>'.PHP_EOL;
23+
$output =' <div class="tag-line">Documentation generated on #REDACTED# by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer #VERSION#</a></div>
24+
</body>
25+
</html>';
2926

30-
return $output;
27+
// Use the correct line endings based on the OS.
28+
return str_replace("\n", PHP_EOL, $output).PHP_EOL;
3129
}
3230

3331
/**

0 commit comments

Comments
 (0)