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 6
6
7
7
class Rectangle
8
8
{
9
- protected string $ content = ' ' ;
9
+ protected string $ content = '' ;
10
10
11
11
/**
12
12
* @throws SideLessThanOneException
@@ -64,22 +64,24 @@ public function draw(LineAsciiCharsInterface|null $lineDrawerProvider = null): s
64
64
$ columns = $ this ->columns + $ sumTheBorders ;
65
65
66
66
$ contentCharPosition = 0 ;
67
+ $ this ->content = str_replace ("\r" , '' , $ this ->content );
67
68
$ contentLength = strlen ($ this ->content );
68
69
69
70
for ($ row = 0 ; $ row < $ this ->rows ; $ row ++) {
70
71
for ($ column = 0 ; $ column < $ columns ; $ column ++) {
71
72
if ($ column == 0 || $ column == ($ columns - 1 )) {
72
73
$ rectangleBox .= $ lineDrawerProvider ->verticalLine ();
73
- } else {
74
- $ add = ' ' ;
74
+ continue ;
75
+ }
75
76
76
- if ($ this ->content != ' ' && $ contentCharPosition < $ contentLength ) {
77
- $ add = $ this ->content [$ contentCharPosition ];
78
- $ contentCharPosition ++;
79
- }
77
+ $ add = ' ' ;
80
78
81
- $ rectangleBox .= $ add ;
79
+ if ($ this ->content != '' && $ contentCharPosition < $ contentLength ) {
80
+ $ add = $ this ->content [$ contentCharPosition ];
81
+ $ contentCharPosition ++;
82
82
}
83
+
84
+ $ rectangleBox .= $ add ;
83
85
}
84
86
85
87
$ rectangleBox .= PHP_EOL ;
You can’t perform that action at this time.
0 commit comments