FluidTYPO3\Vhs\ViewHelpers\Math\AbstractMultipleMathViewHelper::calculate PHP Method

calculate() protected method

protected calculate ( mixed $a, mixed $b = null ) : mixed
$a mixed
$b mixed
return mixed
    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);
    }
AbstractMultipleMathViewHelper