File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 66
77class 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 ;
You can’t perform that action at this time.
0 commit comments