Mercurial > hg > cmmr2012-drupal-site
diff vendor/sebastian/comparator/src/DOMNodeComparator.php @ 2:5311817fb629
Theme updates
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 13:19:18 +0000 |
parents | c75dbcec494b |
children |
line wrap: on
line diff
--- a/vendor/sebastian/comparator/src/DOMNodeComparator.php Thu Jul 05 15:32:06 2018 +0100 +++ b/vendor/sebastian/comparator/src/DOMNodeComparator.php Tue Jul 10 13:19:18 2018 +0000 @@ -1,6 +1,6 @@ <?php /* - * This file is part of the Comparator package. + * This file is part of sebastian/comparator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * @@ -21,8 +21,9 @@ /** * Returns whether the comparator can compare two values. * - * @param mixed $expected The first value to compare - * @param mixed $actual The second value to compare + * @param mixed $expected The first value to compare + * @param mixed $actual The second value to compare + * * @return bool */ public function accepts($expected, $actual) @@ -42,17 +43,13 @@ * * @throws ComparisonFailure */ - public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array()) + public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = []) { $expectedAsString = $this->nodeToText($expected, true, $ignoreCase); $actualAsString = $this->nodeToText($actual, true, $ignoreCase); if ($expectedAsString !== $actualAsString) { - if ($expected instanceof DOMDocument) { - $type = 'documents'; - } else { - $type = 'nodes'; - } + $type = $expected instanceof DOMDocument ? 'documents' : 'nodes'; throw new ComparisonFailure( $expected, @@ -60,7 +57,7 @@ $expectedAsString, $actualAsString, false, - sprintf("Failed asserting that two DOM %s are equal.\n", $type) + \sprintf("Failed asserting that two DOM %s are equal.\n", $type) ); } } @@ -68,40 +65,23 @@ /** * Returns the normalized, whitespace-cleaned, and indented textual * representation of a DOMNode. - * - * @param DOMNode $node - * @param bool $canonicalize - * @param bool $ignoreCase - * @return string */ - private function nodeToText(DOMNode $node, $canonicalize, $ignoreCase) + private function nodeToText(DOMNode $node, bool $canonicalize, bool $ignoreCase): string { if ($canonicalize) { $document = new DOMDocument; - $document->loadXML($node->C14N()); + @$document->loadXML($node->C14N()); $node = $document; } - if ($node instanceof DOMDocument) { - $document = $node; - } else { - $document = $node->ownerDocument; - } + $document = $node instanceof DOMDocument ? $node : $node->ownerDocument; $document->formatOutput = true; $document->normalizeDocument(); - if ($node instanceof DOMDocument) { - $text = $node->saveXML(); - } else { - $text = $document->saveXML($node); - } + $text = $node instanceof DOMDocument ? $node->saveXML() : $document->saveXML($node); - if ($ignoreCase) { - $text = strtolower($text); - } - - return $text; + return $ignoreCase ? $text : \strtolower($text); } }