Skip to content

Commit a13cdfd

Browse files
authored
Merge pull request #724 from PHPCSStandards/feature/generators-add-tests-code-sample_
Generators/Text::printTitle(): minor tweaks
2 parents becac94 + aed8d93 commit a13cdfd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Generators/Text.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
* Output is designed to be displayed in a terminal and is wrapped to 100 characters.
66
*
77
* @author Greg Sherwood <gsherwood@squiz.net>
8+
* @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl>
89
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
10+
* @copyright 2024 PHPCSStandards and contributors
911
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
1012
*/
1113

@@ -52,13 +54,15 @@ public function processSniff(DOMNode $doc)
5254
*/
5355
protected function printTitle(DOMNode $doc)
5456
{
55-
$title = $this->getTitle($doc);
56-
$standard = $this->ruleset->name;
57+
$title = $this->getTitle($doc);
58+
$standard = $this->ruleset->name;
59+
$displayTitle = "$standard CODING STANDARD: $title";
60+
$titleLength = strlen($displayTitle);
5761

5862
echo PHP_EOL;
59-
echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4));
60-
echo strtoupper(PHP_EOL."| $standard CODING STANDARD: $title |".PHP_EOL);
61-
echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4));
63+
echo str_repeat('-', ($titleLength + 4));
64+
echo strtoupper(PHP_EOL."| $displayTitle |".PHP_EOL);
65+
echo str_repeat('-', ($titleLength + 4));
6266
echo PHP_EOL.PHP_EOL;
6367

6468
}//end printTitle()

0 commit comments

Comments
 (0)