- var_dump: documentation ( source)
- ceil: documentation ( source)
- max: documentation ( source)
- min: documentation ( source)
- pow: documentation ( source)
<?php
function getBatchSize(int $totalRecordsCount) : int
{
$batchSize = (int) ceil($totalRecordsCount / 5000);
$roundDivisor = pow(10, strlen((string) $batchSize) - 1);
$batchSize = (int) ceil($batchSize / $roundDivisor) * $roundDivisor;
var_dump($batchSize);
return max(
10,
min(100, $batchSize)
);
}
var_dump(getBatchSize(212522), '---');
var_dump(getBatchSize(2125223), '---');