This repository was archived by the owner on Jan 31, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
src/Helper/Placeholder/Container Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -117,14 +117,17 @@ public function toString($indent = null)
117
117
? $ this ->getWhitespace ($ indent )
118
118
: $ this ->getIndent ();
119
119
120
- $ items = $ this ->getArrayCopy ();
121
120
// If we don't have items - do not show prefix and postfix
122
- if (!count ($ items )) {
121
+ if (!$ this -> count ()) {
123
122
return '' ;
124
123
}
124
+
125
+ $ itemsToString = implode ($ this ->getSeparator (), $ this ->getArrayCopy ());
126
+ // todo check empty $itemsToString after trim() to return ''
127
+
125
128
$ return = $ indent
126
129
. $ this ->getPrefix ()
127
- . implode ( $ this -> getSeparator (), $ items )
130
+ . $ itemsToString
128
131
. $ this ->getPostfix ();
129
132
$ return = preg_replace ("/( \r\n?| \n)/ " , '$1 ' . $ indent , $ return );
130
133
Original file line number Diff line number Diff line change @@ -432,4 +432,13 @@ public function testIndentationIsHonored()
432
432
$ this ->assertContains (" <ul> \n" , $ string , $ string );
433
433
$ this ->assertContains ("\n </ul> " , $ string , $ string );
434
434
}
435
+
436
+ public function testNoUsePrefixPostfixIfNoItems ()
437
+ {
438
+ $ this ->container ->setPrefix ("<h1> " )
439
+ ->setPostfix ("</h1> " );
440
+ $ string = $ this ->container ->toString ();
441
+ $ this ->assertEquals ('' , $ string );
442
+ }
443
+
435
444
}
You can’t perform that action at this time.
0 commit comments