@@ 330-345 (lines=16) @@ | ||
327 | * |
|
328 | * @return SimpleHtmlDomInterface |
|
329 | */ |
|
330 | public function setAttribute(string $name, $value = null, bool $strict = false): SimpleHtmlDomInterface |
|
331 | { |
|
332 | if ( |
|
333 | ($strict && $value === null) |
|
334 | || |
|
335 | (!$strict && empty($value)) |
|
336 | ) { |
|
337 | /** @noinspection UnusedFunctionResultInspection */ |
|
338 | $this->removeAttribute($name); |
|
339 | } elseif (\method_exists($this->node, 'setAttribute')) { |
|
340 | /** @noinspection UnusedFunctionResultInspection */ |
|
341 | $this->node->setAttribute($name, $value); |
|
342 | } |
|
343 | ||
344 | return $this; |
|
345 | } |
|
346 | ||
347 | /** |
|
348 | * Get dom node's plain text. |
@@ 287-302 (lines=16) @@ | ||
284 | * |
|
285 | * @return SimpleXmlDomInterface |
|
286 | */ |
|
287 | public function setAttribute(string $name, $value = null, bool $strict = false): SimpleXmlDomInterface |
|
288 | { |
|
289 | if ( |
|
290 | ($strict && $value === null) |
|
291 | || |
|
292 | (!$strict && empty($value)) |
|
293 | ) { |
|
294 | /** @noinspection UnusedFunctionResultInspection */ |
|
295 | $this->removeAttribute($name); |
|
296 | } elseif (\method_exists($this->node, 'setAttribute')) { |
|
297 | /** @noinspection UnusedFunctionResultInspection */ |
|
298 | $this->node->setAttribute($name, $value); |
|
299 | } |
|
300 | ||
301 | return $this; |
|
302 | } |
|
303 | ||
304 | /** |
|
305 | * Get dom node's plain text. |