4
4
5
5
namespace Eightfold \XMLBuilder ;
6
6
7
+ use Eightfold \XMLBuilder \Contracts \Buildable ;
8
+ use Eightfold \XMLBuilder \Contracts \Contentable ;
9
+
7
10
use Stringable ;
8
11
9
- use Eightfold \XMLBuilder \Callables \ PropertyArrayToString ;
12
+ use Eightfold \XMLBuilder \Concatenate ;
10
13
11
- use Eightfold \XMLBuilder \Contracts \Buildable ;
12
- use Eightfold \XMLBuilder \Contracts \Contentable ;
14
+ use Eightfold \XMLBuilder \Callables \PropertyArrayToString ;
13
15
14
16
use Eightfold \XMLBuilder \Implementations \Properties as PropertiesImp ;
15
17
use Eightfold \XMLBuilder \Implementations \Buildable as BuildableImp ;
@@ -27,14 +29,7 @@ class Document implements Buildable, Contentable
27
29
28
30
private string $ standalone = 'yes ' ;
29
31
30
- final private function __construct (
31
- private string $ name ,
32
- string |Stringable ...$ content
33
- ) {
34
- $ this ->content = $ content ;
35
- }
36
-
37
- public function setVersion (string |float |int $ version ): self
32
+ public function withVersion (string |float |int $ version ): self
38
33
{
39
34
if (is_int ($ version )) {
40
35
$ version = strval ($ version ) . '.0 ' ;
@@ -43,24 +38,48 @@ public function setVersion(string|float|int $version): self
43
38
return $ this ;
44
39
}
45
40
46
- public function setEncoding (string $ encoding ): self
41
+ /**
42
+ * @deprecated 1.4 Use `withVersion` instead.
43
+ */
44
+ public function setVersion (string |float |int $ version ): self
45
+ {
46
+ return $ this ->withVersion ($ version );
47
+ }
48
+
49
+ public function withEncoding (string $ encoding ): self
47
50
{
48
51
$ this ->encoding = $ encoding ;
49
52
return $ this ;
50
53
}
51
54
55
+ /**
56
+ * @deprecated 1.4 Use `withEncoding` instead.
57
+ */
58
+ public function setEncoding (string $ encoding ): self
59
+ {
60
+ return $ this ->withEncoding ($ encoding );
61
+ }
62
+
52
63
public function removeEncoding (): self
53
64
{
54
65
$ this ->encoding = '' ;
55
66
return $ this ;
56
67
}
57
68
58
- public function setStandalone (bool $ standalone = true ): self
69
+ public function withStandalone (bool $ standalone ): self
59
70
{
60
71
$ this ->standalone = ($ standalone ) ? 'yes ' : 'no ' ;
61
72
return $ this ;
62
73
}
63
74
75
+ /**
76
+ * @deprecated 1.4 Use `withStandalone` instead.
77
+ */
78
+ public function setStandalone (bool $ standalone = true ): self
79
+ {
80
+ return $ this ->withStandalone ($ standalone );
81
+ }
82
+
64
83
public function removeStandalone (): self
65
84
{
66
85
$ this ->standalone = '' ;
@@ -83,7 +102,9 @@ public function __toString(): string
83
102
$ doctype =
84
103
'<?xml ' . PropertyArrayToString::convert (...$ declarationProps ) . ' ?> '
85
104
. "\n" ;
86
- return $ doctype . $ this ->opening () . implode ('' , $ this ->content )
105
+ return $ doctype
106
+ . $ this ->opening ()
107
+ . Concatenate::create (...$ this ->content )
87
108
. $ this ->closing ();
88
109
}
89
110
0 commit comments