1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-09-25 21:49:04 +02:00

Merge pull request #164 from peter-gribanov/tests

Tests
This commit is contained in:
Tomáš Votruba
2019-09-18 09:27:19 +02:00
committed by GitHub

View File

@@ -25,14 +25,21 @@ foreach ($readMeFile as $lineNumber => $line) {
} }
$tableOfContentsStarted = false; $tableOfContentsStarted = false;
$chaptersFound[] = sprintf('%s [%s](#%s)', if (strlen($matches['depth']) === 2) {
strlen($matches['depth']) === 2 $depth = sprintf(' %s.', ++$manIndex);
? sprintf(' %s.', ++$manIndex) } else {
: ' *' $depth = sprintf(' %s*', str_repeat(' ', strlen($matches['depth']) - 1));
, }
$matches['title'],
preg_replace(['/ /', '/[^-\w]+/'], ['-', ''], strtolower($matches['title'])) // ignore links in title
); $matches['title'] = preg_replace('/\[([^\]]+)\]\((?:[^\)]+)\)/u', '$1', $matches['title']);
$link = $matches['title'];
$link = strtolower($link);
$link = str_replace(' ', '-', $link);
$link = preg_replace('/[^-\w]+/u', '', $link);
$chaptersFound[] = sprintf('%s [%s](#%s)', $depth, $matches['title'], $link);
} }
if ($tableOfContentsStarted === true && isset($line[0])) { if ($tableOfContentsStarted === true && isset($line[0])) {
$currentTableOfContentsChapters[] = $line; $currentTableOfContentsChapters[] = $line;