protected function calculate($a, $b = null)
{
if ($b === null) {
throw new Exception('Required argument "b" was not supplied', 1237823699);
}
$aIsIterable = $this->assertIsArrayOrIterator($a);
$bIsIterable = $this->assertIsArrayOrIterator($b);
if (true === $aIsIterable) {
$a = $this->arrayFromArrayOrTraversableOrCSV($a);
foreach ($a as $index => $value) {
$bSideValue = true === $bIsIterable ? $b[$index] : $b;
$a[$index] = $this->calculateAction($value, $bSideValue);
}
return $a;
} elseif (true === $bIsIterable) {
// condition matched if $a is not iterable but $b is.
throw new Exception('Math operation attempted using an iterator $b against a numeric value $a. Either both $a and $b, ' . 'or only $a, must be array/Iterator', 1351890876);
}
return $this->calculateAction($a, $b);
}