@@ 315-330 (lines=16) @@ | ||
312 | * |
|
313 | * @return SimpleHtmlDomInterface |
|
314 | */ |
|
315 | public function setAttribute(string $name, $value = null, bool $strict = false): SimpleHtmlDomInterface |
|
316 | { |
|
317 | if ( |
|
318 | ($strict && $value === null) |
|
319 | || |
|
320 | (!$strict && empty($value)) |
|
321 | ) { |
|
322 | /** @noinspection UnusedFunctionResultInspection */ |
|
323 | $this->removeAttribute($name); |
|
324 | } elseif (\method_exists($this->node, 'setAttribute')) { |
|
325 | /** @noinspection UnusedFunctionResultInspection */ |
|
326 | $this->node->setAttribute($name, $value); |
|
327 | } |
|
328 | ||
329 | return $this; |
|
330 | } |
|
331 | ||
332 | /** |
|
333 | * Get dom node's plain text. |
@@ 277-292 (lines=16) @@ | ||
274 | * |
|
275 | * @return SimpleXmlDomInterface |
|
276 | */ |
|
277 | public function setAttribute(string $name, $value = null, bool $strict = false): SimpleXmlDomInterface |
|
278 | { |
|
279 | if ( |
|
280 | ($strict && $value === null) |
|
281 | || |
|
282 | (!$strict && empty($value)) |
|
283 | ) { |
|
284 | /** @noinspection UnusedFunctionResultInspection */ |
|
285 | $this->removeAttribute($name); |
|
286 | } elseif (\method_exists($this->node, 'setAttribute')) { |
|
287 | /** @noinspection UnusedFunctionResultInspection */ |
|
288 | $this->node->setAttribute($name, $value); |
|
289 | } |
|
290 | ||
291 | return $this; |
|
292 | } |
|
293 | ||
294 | /** |
|
295 | * Get dom node's plain text. |