| @@ 296-311 (lines=16) @@ | ||
| 293 | * |
|
| 294 | * @return SimpleHtmlDomInterface |
|
| 295 | */ |
|
| 296 | public function setAttribute(string $name, $value = null, bool $strict = false): SimpleHtmlDomInterface |
|
| 297 | { |
|
| 298 | if ( |
|
| 299 | ($strict && $value === null) |
|
| 300 | || |
|
| 301 | (!$strict && empty($value)) |
|
| 302 | ) { |
|
| 303 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 304 | $this->removeAttribute($name); |
|
| 305 | } elseif (\method_exists($this->node, 'setAttribute')) { |
|
| 306 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 307 | $this->node->setAttribute($name, $value); |
|
| 308 | } |
|
| 309 | ||
| 310 | return $this; |
|
| 311 | } |
|
| 312 | ||
| 313 | /** |
|
| 314 | * Get dom node's plain text. |
|
| @@ 258-273 (lines=16) @@ | ||
| 255 | * |
|
| 256 | * @return SimpleXmlDomInterface |
|
| 257 | */ |
|
| 258 | public function setAttribute(string $name, $value = null, bool $strict = false): SimpleXmlDomInterface |
|
| 259 | { |
|
| 260 | if ( |
|
| 261 | ($strict && $value === null) |
|
| 262 | || |
|
| 263 | (!$strict && empty($value)) |
|
| 264 | ) { |
|
| 265 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 266 | $this->removeAttribute($name); |
|
| 267 | } elseif (\method_exists($this->node, 'setAttribute')) { |
|
| 268 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 269 | $this->node->setAttribute($name, $value); |
|
| 270 | } |
|
| 271 | ||
| 272 | return $this; |
|
| 273 | } |
|
| 274 | ||
| 275 | /** |
|
| 276 | * Get dom node's plain text. |
|