fix: cast SAW operands to float to prevent TypeError on production PHP
This commit is contained in:
parent
5f54fe7db9
commit
675c05537e
|
|
@ -453,10 +453,10 @@ private function prosesMetodeSAWKontrakan($items, $kriteria, $customBobot = null
|
||||||
// Normalisasi based on tipe (Benefit/Cost)
|
// Normalisasi based on tipe (Benefit/Cost)
|
||||||
if (strtolower($k->tipe) === 'benefit') {
|
if (strtolower($k->tipe) === 'benefit') {
|
||||||
$maxVal = $maxValues[$field] ?: 1;
|
$maxVal = $maxValues[$field] ?: 1;
|
||||||
$row['normalisasi'][$field] = $nilai / $maxVal;
|
$row['normalisasi'][$field] = (float)$nilai / (float)$maxVal;
|
||||||
} else { // Cost
|
} else { // Cost
|
||||||
$minVal = $minValues[$field] ?: 1;
|
$minVal = $minValues[$field] ?: 1;
|
||||||
$row['normalisasi'][$field] = $nilai > 0 ? $minVal / $nilai : 0;
|
$row['normalisasi'][$field] = (float)$nilai > 0 ? (float)$minVal / (float)$nilai : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -533,10 +533,10 @@ private function prosesMetodeSAWLaundry($items, $kriteria, $customBobot = null,
|
||||||
// Normalisasi based on tipe (Benefit/Cost)
|
// Normalisasi based on tipe (Benefit/Cost)
|
||||||
if (strtolower($k->tipe) === 'benefit') {
|
if (strtolower($k->tipe) === 'benefit') {
|
||||||
$maxVal = $maxValues[$field] ?: 1;
|
$maxVal = $maxValues[$field] ?: 1;
|
||||||
$row['normalisasi'][$field] = $nilai / $maxVal;
|
$row['normalisasi'][$field] = (float)$nilai / (float)$maxVal;
|
||||||
} else { // Cost
|
} else { // Cost
|
||||||
$minVal = $minValues[$field] ?: 1;
|
$minVal = $minValues[$field] ?: 1;
|
||||||
$row['normalisasi'][$field] = $nilai > 0 ? $minVal / $nilai : 0;
|
$row['normalisasi'][$field] = (float)$nilai > 0 ? (float)$minVal / (float)$nilai : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue