Class Test extends AbstractTest {
public function calculateFee(array $weightArray, int $amount) : int
{
$weights = $this->arrayToCollection($weightArray);
$amount = $this->loopWeights(function (int $weight) {
return (100 + $weight * 10);
});
return $amount;
}
}
abstract Class AbstractTest {
protected function loopWeights(callable $closure): int
{
foreach ($weights as $weight) {
$amount = $amount + $closure($weight);
}
return $amount;
}
}