Skip to content

Commit

Permalink
Remove unnecessary else
Browse files Browse the repository at this point in the history
  • Loading branch information
terremoth committed Feb 22, 2024
1 parent c07be1f commit 8f9a2e2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/BoxDesigner/Rectangle.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Rectangle
{
protected string $content = ' ';
protected string $content = '';

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

$contentCharPosition = 0;
$this->content = str_replace("\r", '', $this->content);
$contentLength = strlen($this->content);

for ($row = 0; $row < $this->rows; $row++) {
for ($column = 0; $column < $columns; $column++) {
if ($column == 0 || $column == ($columns - 1)) {
$rectangleBox .= $lineDrawerProvider->verticalLine();
} else {
$add = ' ';
continue;
}

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

$rectangleBox .= $add;
if ($this->content != '' && $contentCharPosition < $contentLength) {
$add = $this->content[$contentCharPosition];
$contentCharPosition++;
}

$rectangleBox .= $add;
}

$rectangleBox .= PHP_EOL;
Expand Down

0 comments on commit 8f9a2e2

Please sign in to comment.