diff --git a/src/ArrayComparator.php b/src/ArrayComparator.php index 4065edd0..98f0cb63 100644 --- a/src/ArrayComparator.php +++ b/src/ArrayComparator.php @@ -85,16 +85,16 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f " %s => %s\n", $this->exporter->export($key), $e->getExpectedAsString() - ? $this->indent($e->getExpectedAsString()) - : $this->exporter->shortenedExport($e->getExpected()) + ? $this->indent($e->getExpectedAsString()) + : $this->exporter->shortenedExport($e->getExpected()) ); $actString .= sprintf( " %s => %s\n", $this->exporter->export($key), $e->getActualAsString() - ? $this->indent($e->getActualAsString()) - : $this->exporter->shortenedExport($e->getActual()) + ? $this->indent($e->getActualAsString()) + : $this->exporter->shortenedExport($e->getActual()) ); $equal = false; diff --git a/src/DOMNodeComparator.php b/src/DOMNodeComparator.php index 6d310157..816e8c2a 100644 --- a/src/DOMNodeComparator.php +++ b/src/DOMNodeComparator.php @@ -49,11 +49,10 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f $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, @@ -69,14 +68,8 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f /** * 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; @@ -85,25 +78,19 @@ private function nodeToText(DOMNode $node, $canonicalize, $ignoreCase) $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); - } - - if ($ignoreCase) { - $text = strtolower($text); - } + $text = $node instanceof DOMDocument + ? $node->saveXML() + : $document->saveXML($node) + ; - return $text; + return $ignoreCase ? $text : strtolower($text); } } diff --git a/src/DateTimeComparator.php b/src/DateTimeComparator.php index bbfdb7a7..b70179cb 100644 --- a/src/DateTimeComparator.php +++ b/src/DateTimeComparator.php @@ -65,15 +65,11 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f * Returns an ISO 8601 formatted string representation of a datetime or * 'Invalid DateTimeInterface object' if the provided DateTimeInterface was not properly * initialized. - * - * @param \DateTimeInterface $datetime - * - * @return string */ - private function dateTimeToString($datetime) + private function dateTimeToString(\DateTimeInterface $datetime): string { $string = $datetime->format('Y-m-d\TH:i:s.uO'); - return $string ? $string : 'Invalid DateTimeInterface object'; + return $string ?: 'Invalid DateTimeInterface object'; } }