eZ\Publish\Core\Persistence\Doctrine\DoctrineExpression::basicMath PHP Method

basicMath() private method

basicMath() accepts an arbitrary number of parameters. Each parameter must contain a value or an expression or an array with values or expressions.
private basicMath ( string $type ) : string
$type string the type of operation, can be '+', '-', '*' or '/'.
return string an expression
    private function basicMath($type)
    {
        $args = func_get_args();
        $elements = $this->arrayFlatten(array_slice($args, 1));
        if (count($elements) < 1) {
            throw new QueryException("The operation '{$type}' expected at least 1 argument but none provided.");
        }
        if (count($elements) == 1) {
            return $elements[0];
        } else {
            return '( ' . implode(" {$type} ", $elements) . ' )';
        }
    }