Skip to content

Commit 8f9a2e2

Browse files
committed
Remove unnecessary else
1 parent c07be1f commit 8f9a2e2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/BoxDesigner/Rectangle.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Rectangle
88
{
9-
protected string $content = ' ';
9+
protected string $content = '';
1010

1111
/**
1212
* @throws SideLessThanOneException
@@ -64,22 +64,24 @@ public function draw(LineAsciiCharsInterface|null $lineDrawerProvider = null): s
6464
$columns = $this->columns + $sumTheBorders;
6565

6666
$contentCharPosition = 0;
67+
$this->content = str_replace("\r", '', $this->content);
6768
$contentLength = strlen($this->content);
6869

6970
for ($row = 0; $row < $this->rows; $row++) {
7071
for ($column = 0; $column < $columns; $column++) {
7172
if ($column == 0 || $column == ($columns - 1)) {
7273
$rectangleBox .= $lineDrawerProvider->verticalLine();
73-
} else {
74-
$add = ' ';
74+
continue;
75+
}
7576

76-
if ($this->content != ' ' && $contentCharPosition < $contentLength) {
77-
$add = $this->content[$contentCharPosition];
78-
$contentCharPosition++;
79-
}
77+
$add = ' ';
8078

81-
$rectangleBox .= $add;
79+
if ($this->content != '' && $contentCharPosition < $contentLength) {
80+
$add = $this->content[$contentCharPosition];
81+
$contentCharPosition++;
8282
}
83+
84+
$rectangleBox .= $add;
8385
}
8486

8587
$rectangleBox .= PHP_EOL;

0 commit comments

Comments
 (0)