Skip to content

Commit

Permalink
refactor: do not rtrim strings without need
Browse files Browse the repository at this point in the history
  • Loading branch information
dbohdan committed Sep 13, 2024
1 parent 544f836 commit 17f3126
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gmi2md.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ final class PreformattedToggleLine implements LineTypeInterface

public static function isType(string $line): bool
{
return str_starts_with(rtrim($line), self::PREFIX);
return str_starts_with($line, self::PREFIX);
}

public static function convert(string $line): string
Expand Down Expand Up @@ -182,9 +182,7 @@ public function convert(string $input): string

private function convertLine(string $line, bool $inPreformatted): array
{
$trimmedLine = rtrim($line);

if (PreformattedToggleLine::isType($trimmedLine)) {
if (PreformattedToggleLine::isType($line)) {
return [
PreformattedToggleLine::class,
$inPreformatted ? PreformattedToggleLine::convert($line) : $line,
Expand All @@ -195,9 +193,9 @@ private function convertLine(string $line, bool $inPreformatted): array
return [PreformattedLine::class, PreformattedLine::convert($line)];
}

$lineType = $this->getLineType($trimmedLine);
$lineType = $this->getLineType($line);

return [$lineType, $lineType::convert($trimmedLine)];
return [$lineType, $lineType::convert(rtrim($line))];
}

private function getLineType(string $line): string
Expand Down

0 comments on commit 17f3126

Please sign in to comment.