-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.php
117 lines (99 loc) · 2.8 KB
/
Node.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
declare(strict_types=1);
namespace Inspirum\XML\Builder;
use DOMDocument;
use DOMNode;
use Inspirum\Arrayable\Model;
use Inspirum\XML\Formatter\Config;
/**
* @extends \Inspirum\Arrayable\Model<int|string,mixed>
*/
interface Node extends Model
{
/**
* Add element to XML node
*
* @param array<string,mixed> $attributes
*
* @throws \DOMException
*/
public function addElement(string $name, array $attributes = [], bool $withNamespaces = true): Node;
/**
* Add text element
*
* @param array<string,mixed> $attributes
*
* @throws \DOMException
*/
public function addTextElement(string $name, mixed $value, array $attributes = [], bool $forcedEscape = false, bool $withNamespaces = true): Node;
/**
* Add element from \DOMNode
*
* @throws \DOMException
*/
public function addElementFromNode(DOMNode $node, bool $forcedEscape = false, bool $withNamespaces = true): Node;
/**
* Append node to parent node.
*/
public function append(Node $element): void;
/**
* Create new (unconnected) element
*
* @param array<string,mixed> $attributes
*
* @throws \DOMException
*/
public function createElement(string $name, array $attributes = [], bool $withNamespaces = true): Node;
/**
* Create new (unconnected) text element
*
* @param array<string,mixed> $attributes
*
* @throws \DOMException
*/
public function createTextElement(string $name, mixed $value, array $attributes = [], bool $forcedEscape = false, bool $withNamespaces = true): Node;
/**
* Create new (unconnected) element from \DOMNode
*
* @throws \DOMException
*/
public function createElementFromNode(DOMNode $node, bool $forcedEscape = false, bool $withNamespaces = true): Node;
/**
* Add XML data
*/
public function addXMLData(string $content): ?Node;
/**
* Get node text content
*/
public function getTextContent(): ?string;
/**
* Get node attributes
*
* @return ($autoCast is true ? array<string,mixed> : array<string,string>)
*/
public function getAttributes(bool $autoCast = false): array;
/**
* @return list<\Inspirum\XML\Builder\Node>|null
*/
public function xpath(string $expression): ?array;
/**
* Get connected \DOMDocument
*/
public function getDocument(): DOMDocument;
/**
* Get connected \DOMNode
*/
public function getNode(): ?DOMNode;
/**
* Return valid XML string.
*
* @throws \DOMException
*/
public function toString(bool $formatOutput = false): string;
/**
* Convert to array
*
* @return array<int|string,mixed>
*/
public function toArray(?Config $config = null): array;
}