You are here

private function DOMNodeComparator::nodeToText in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/sebastian/comparator/src/DOMNodeComparator.php \SebastianBergmann\Comparator\DOMNodeComparator::nodeToText()

Returns the normalized, whitespace-cleaned, and indented textual representation of a DOMNode.

Parameters

DOMNode $node:

bool $canonicalize:

bool $ignoreCase:

Return value

string

1 call to DOMNodeComparator::nodeToText()
DOMNodeComparator::assertEquals in vendor/sebastian/comparator/src/DOMNodeComparator.php
Asserts that two values are equal.

File

vendor/sebastian/comparator/src/DOMNodeComparator.php, line 80

Class

DOMNodeComparator
Compares DOMNode instances for equality.

Namespace

SebastianBergmann\Comparator

Code

private function nodeToText(DOMNode $node, $canonicalize, $ignoreCase) {
  if ($canonicalize) {
    $document = new DOMDocument();
    $document
      ->loadXML($node
      ->C14N());
    $node = $document;
  }
  if ($node instanceof DOMDocument) {
    $document = $node;
  }
  else {
    $document = $node->ownerDocument;
  }
  $document->formatOutput = true;
  $document
    ->normalizeDocument();
  if ($node instanceof DOMDocument) {
    $text = $node
      ->saveXML();
  }
  else {
    $text = $document
      ->saveXML($node);
  }
  if ($ignoreCase) {
    $text = strtolower($text);
  }
  return $text;
}