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 +14
-7
lines changed
src/Helper/Placeholder/Container Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -113,21 +113,19 @@ public function __toString()
113
113
*/
114
114
public function toString ($ indent = null )
115
115
{
116
- $ indent = ($ indent !== null )
117
- ? $ this ->getWhitespace ($ indent )
118
- : $ this ->getIndent ();
119
-
120
116
// If we don't have items - do not show prefix and postfix
121
117
if (!$ this ->count ()) {
122
118
return '' ;
123
119
}
124
120
125
- $ itemsToString = implode ($ this ->getSeparator (), $ this ->getArrayCopy ());
126
- // todo check empty $itemsToString after trim() to return ''
121
+ $ indent = ($ indent !== null )
122
+ ? $ this ->getWhitespace ($ indent )
123
+ : $ this ->getIndent ();
127
124
125
+ $ items = $ this ->getArrayCopy ();
128
126
$ return = $ indent
129
127
. $ this ->getPrefix ()
130
- . $ itemsToString
128
+ . implode ( $ this -> getSeparator (), $ items )
131
129
. $ this ->getPostfix ();
132
130
$ return = preg_replace ("/( \r\n?| \n)/ " , '$1 ' . $ indent , $ return );
133
131
Original file line number Diff line number Diff line change @@ -441,4 +441,13 @@ public function testNoUsePrefixPostfixIfNoItems()
441
441
$ this ->assertEquals ('' , $ string );
442
442
}
443
443
444
+ public function testUsePrefixPostfixIfEmptyItems ()
445
+ {
446
+ $ this ->container ->setPrefix ("<h1> " )
447
+ ->setPostfix ("</h1> " );
448
+ $ this ->container ->set ('' );
449
+ $ string = $ this ->container ->toString ();
450
+ $ this ->assertEquals ('<h1></h1> ' , $ string );
451
+ }
452
+
444
453
}
You can’t perform that action at this time.
0 commit comments