PHPUnit_Util_XML::getNodeText PHP Method

getNodeText() protected static method

Get the text value of this node's child text node.
Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
protected static getNodeText ( DOMNode $node ) : string
$node DOMNode
return string
    protected static function getNodeText(DOMNode $node)
    {
        if (!$node->childNodes instanceof DOMNodeList) {
            return '';
        }
        $result = '';
        foreach ($node->childNodes as $childNode) {
            if ($childNode->nodeType === XML_TEXT_NODE) {
                $result .= trim($childNode->data) . ' ';
            } else {
                $result .= self::getNodeText($childNode);
            }
        }
        return str_replace('  ', ' ', $result);
    }