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