File tree Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ namespace Eightfold \XMLBuilder ;
5
+
6
+ use Eightfold \XMLBuilder \Contracts \Buildable ;
7
+
8
+ use Stringable ;
9
+
10
+ use Eightfold \XMLBuilder \Implementations \Buildable as BuildableImp ;
11
+
12
+ class Concatenate implements Buildable
13
+ {
14
+ use BuildableImp;
15
+
16
+ /**
17
+ * @var array<string|Stringable>
18
+ */
19
+ private array $ content = [];
20
+
21
+ public static function create (string |Stringable ...$ content ): self
22
+ {
23
+ return new self (...$ content );
24
+ }
25
+
26
+ final private function __construct (string |Stringable ...$ content )
27
+ {
28
+ $ this ->content = $ content ;
29
+ }
30
+
31
+ public function __toString (): string
32
+ {
33
+ return implode ('' , $ this ->content );
34
+ }
35
+ }
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ trait Contentable
14
14
private array $ content = [];
15
15
16
16
/**
17
- * @param array<string|String > $content
17
+ * @param array<string|Stringable > $content
18
18
*/
19
19
public static function __callStatic (
20
20
string $ name ,
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Eightfold \XMLBuilder \Tests ;
6
+
7
+ use PHPUnit \Framework \TestCase ;
8
+
9
+ use Eightfold \XMLBuilder \Concatenate ;
10
+
11
+ use Eightfold \XMLBuilder \Element ;
12
+
13
+ class ConcatenateBaselineTest extends TestCase
14
+ {
15
+ /**
16
+ * @test
17
+ */
18
+ public function concatenate_expected_content (): void
19
+ {
20
+ $ expected = '<p>Hello, World!</p> Testing additional string. ' ;
21
+
22
+ $ result = (string ) Concatenate::create (
23
+ Element::p ('Hello, World! ' ),
24
+ ' Testing additional string. '
25
+ );
26
+
27
+ $ this ->assertSame (
28
+ $ expected ,
29
+ $ result
30
+ );
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments