private function replace(string $selector, callable $callback = null): self {
        $nodes = $this->document()->find($selector);

        foreach ($nodes as $node) {
            if (is_null($callback) || $callback($node)) {
                $node->replaceWith(new Text((string)$node->text()));
            }
        }

        return $this;
    }
private function replace(string $selector, callable $callback = null): self {
        $nodes = $this->document()->find($selector);

        foreach ($nodes as $node) {
            if (is_null($callback) || $callback($node)) {
                $node->replaceWith(new Text((string)$node->text()));
            }
        }

        return $this;
    }
private function replace ( string $ selector , callable $ callback = null ) : self { $ nodes = $ this -> document ( ) -> find ( $ selector ) ; foreach ( $ nodes as $ node ) { if ( is_null ( $ callback ) || $ callback ( $ node ) ) { $ node -> replaceWith ( new Text ( ( string ) $ node -> text ( ) ) ) ; } } return $ this ; }
Replace node with its textual contents via CSS selectors

@param string $selector
@param callable $callback

@return self
Replace node with its textual contents via CSS selectors