Skip to content

Commit

Permalink
Update CS
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacePossum authored and sebastianbergmann committed Aug 3, 2017
1 parent 875bd7c commit c42cbbe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
8 changes: 4 additions & 4 deletions src/ArrayComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
41 changes: 14 additions & 27 deletions src/DOMNodeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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);
}
}
8 changes: 2 additions & 6 deletions src/DateTimeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}

0 comments on commit c42cbbe

Please sign in to comment.