| @@ 322-337 (lines=16) @@ | ||
| 319 | * |
|
| 320 | * @return SimpleHtmlDomInterface |
|
| 321 | */ |
|
| 322 | public function setAttribute(string $name, $value = null, bool $strict = false): SimpleHtmlDomInterface |
|
| 323 | { |
|
| 324 | if ( |
|
| 325 | ($strict && $value === null) |
|
| 326 | || |
|
| 327 | (!$strict && empty($value)) |
|
| 328 | ) { |
|
| 329 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 330 | $this->removeAttribute($name); |
|
| 331 | } elseif (\method_exists($this->node, 'setAttribute')) { |
|
| 332 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 333 | $this->node->setAttribute($name, $value); |
|
| 334 | } |
|
| 335 | ||
| 336 | return $this; |
|
| 337 | } |
|
| 338 | ||
| 339 | /** |
|
| 340 | * Get dom node's plain text. |
|
| @@ 283-298 (lines=16) @@ | ||
| 280 | * |
|
| 281 | * @return SimpleXmlDomInterface |
|
| 282 | */ |
|
| 283 | public function setAttribute(string $name, $value = null, bool $strict = false): SimpleXmlDomInterface |
|
| 284 | { |
|
| 285 | if ( |
|
| 286 | ($strict && $value === null) |
|
| 287 | || |
|
| 288 | (!$strict && empty($value)) |
|
| 289 | ) { |
|
| 290 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 291 | $this->removeAttribute($name); |
|
| 292 | } elseif (\method_exists($this->node, 'setAttribute')) { |
|
| 293 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 294 | $this->node->setAttribute($name, $value); |
|
| 295 | } |
|
| 296 | ||
| 297 | return $this; |
|
| 298 | } |
|
| 299 | ||
| 300 | /** |
|
| 301 | * Get dom node's plain text. |
|