@@ -100,21 +100,26 @@ public function appendChild($nodes)
100
100
* @param string $string HTML or XML string or file path
101
101
* @param bool $isFile indicates that in first parameter was passed to the file path
102
102
* @param string $type Type of document
103
+ * @param int $options Additional parameters
103
104
*/
104
- public function load ($ string , $ isFile = false , $ type = 'html ' )
105
+ public function load ($ string , $ isFile = false , $ type = 'html ' , $ options = 0 )
105
106
{
106
107
if (!is_string ($ string )) {
107
108
throw new InvalidArgumentException (sprintf ('%s expects parameter 1 to be string, %s given ' , __METHOD__ , (is_object ($ string ) ? get_class ($ string ) : gettype ($ string ))));
108
109
}
109
110
110
- if ($ isFile ) {
111
- $ string = $ this ->loadFile ($ string );
112
- }
113
-
114
111
if (!in_array (strtolower ($ type ), ['xml ' , 'html ' ])) {
115
112
throw new InvalidArgumentException (sprintf ('Document type must be "xml" or "html", %s given ' , __METHOD__ , (is_object ($ type ) ? get_class ($ type ) : gettype ($ type ))));
116
113
}
117
114
115
+ if (!is_integer ($ options )) {
116
+ throw new InvalidArgumentException (sprintf ('%s expects parameter 4 to be integer, %s given ' , __METHOD__ , (is_object ($ options ) ? get_class ($ options ) : gettype ($ options ))));
117
+ }
118
+
119
+ if ($ isFile ) {
120
+ $ string = $ this ->loadFile ($ string );
121
+ }
122
+
118
123
if (substr ($ string , 0 , 5 ) !== '<?xml ' ) {
119
124
$ prolog = sprintf ('<?xml version="1.0" encoding="%s"?> ' , $ this ->document ->encoding );
120
125
@@ -126,7 +131,7 @@ public function load($string, $isFile = false, $type = 'html')
126
131
libxml_use_internal_errors (true );
127
132
libxml_disable_entity_loader (true );
128
133
129
- $ this ->type === 'xml ' ? $ this ->document ->loadXml ($ string ) : $ this ->document ->loadHtml ($ string );
134
+ $ this ->type === 'xml ' ? $ this ->document ->loadXml ($ string, $ options ) : $ this ->document ->loadHtml ($ string, $ options );
130
135
131
136
libxml_clear_errors ();
132
137
@@ -140,60 +145,64 @@ public function load($string, $isFile = false, $type = 'html')
140
145
* Load HTML from a string.
141
146
*
142
147
* @param string $html The HTML string
148
+ * @param int $options Additional parameters
143
149
*
144
150
* @return \DiDom\Document
145
151
*
146
152
* @throws \InvalidArgumentException if the provided argument is not a string
147
153
*/
148
- public function loadHtml ($ html )
154
+ public function loadHtml ($ html, $ options = 0 )
149
155
{
150
- return $ this ->load ($ html , false , 'html ' );
156
+ return $ this ->load ($ html , false , 'html ' , $ options );
151
157
}
152
158
153
159
/**
154
160
* Load HTML from a file.
155
161
*
156
162
* @param string $filepath The path to the HTML file
163
+ * @param int $options Additional parameters
157
164
*
158
165
* @return \DiDom\Document
159
166
*
160
167
* @throws \InvalidArgumentException if the file path is not a string
161
168
* @throws \RuntimeException if the file does not exist
162
169
* @throws \RuntimeException if you are unable to load the file
163
170
*/
164
- public function loadHtmlFile ($ filepath )
171
+ public function loadHtmlFile ($ filepath, $ options = 0 )
165
172
{
166
- return $ this ->load ($ filepath , true , 'html ' );
173
+ return $ this ->load ($ filepath , true , 'html ' , $ options );
167
174
}
168
175
169
176
/**
170
177
* Load XML from a string.
171
178
*
172
179
* @param string $xml The XML string
180
+ * @param int $options Additional parameters
173
181
*
174
182
* @return \DiDom\Document
175
183
*
176
184
* @throws \InvalidArgumentException if the provided argument is not a string
177
185
*/
178
- public function loadXml ($ xml )
186
+ public function loadXml ($ xml, $ options = 0 )
179
187
{
180
- return $ this ->load ($ xml , false , 'xml ' );
188
+ return $ this ->load ($ xml , false , 'xml ' , $ options );
181
189
}
182
190
183
191
/**
184
192
* Load XML from a file.
185
193
*
186
194
* @param string $filepath The path to the XML file
195
+ * @param int $options Additional parameters
187
196
*
188
197
* @return \DiDom\Document
189
198
*
190
199
* @throws \InvalidArgumentException if the file path is not a string
191
200
* @throws \RuntimeException if the file does not exist
192
201
* @throws \RuntimeException if you are unable to load the file
193
202
*/
194
- public function loadXmlFile ($ filepath )
203
+ public function loadXmlFile ($ filepath, $ options = 0 )
195
204
{
196
- return $ this ->load ($ filepath , true , 'xml ' );
205
+ return $ this ->load ($ filepath , true , 'xml ' , $ options );
197
206
}
198
207
199
208
/**
0 commit comments