Skip to content

Commit

Permalink
apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jul 4, 2024
1 parent 8b5e4a5 commit fa08a0b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/DataTable/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,18 +521,18 @@ private function getColumnValuesMerged($operation, $thisColumnValue, $columnToSu
$newValue = null;
break;
case 'max':
if (null === $thisColumnValue || false === $thisColumnValue || '' === $thisColumnValue) {
if ($this->isValueConsideredEmpty($thisColumnValue)) {
$newValue = $columnToSumValue;
} elseif (null === $columnToSumValue || false === $columnToSumValue || '' === $columnToSumValue) {
} elseif ($this->isValueConsideredEmpty($columnToSumValue)) {
$newValue = $thisColumnValue;
} else {
$newValue = max($thisColumnValue, $columnToSumValue);
}
break;
case 'min':
if (null === $thisColumnValue || false === $thisColumnValue || '' === $thisColumnValue) {
if ($this->isValueConsideredEmpty($thisColumnValue)) {
$newValue = $columnToSumValue;
} elseif (null === $columnToSumValue || false === $columnToSumValue || '' === $columnToSumValue) {
} elseif ($this->isValueConsideredEmpty($columnToSumValue)) {
$newValue = $thisColumnValue;
} else {
$newValue = min($thisColumnValue, $columnToSumValue);
Expand Down Expand Up @@ -564,6 +564,11 @@ private function getColumnValuesMerged($operation, $thisColumnValue, $columnToSu
return $newValue;
}

private function isValueConsideredEmpty($value): bool
{
return in_array($value, [null, false, ''], true);
}

/**
* Sums the metadata in `$rowToSum` with the metadata in `$this` row.
*
Expand Down

0 comments on commit fa08a0b

Please sign in to comment.