<?php

namespace Profideo\FormulaInterpreterBundle\Excel\ExpressionLanguage\ExpressionFunction;

/**
 * Represents the "ROUND" function that can be used in an expression.
 */
class RoundExpressionFunction extends ExpressionFunction
{
    /**
     * @return string
     */
    protected function getCompilerFunction()
    {
        return sprintf('%s(%s, %s)', $this->getName(), func_get_arg(0), func_get_arg(1));
    }

    /**
     * @return float
     */
    protected function getEvaluatorFunction()
    {
        return round(func_get_arg(1), func_get_arg(2), PHP_ROUND_HALF_UP);
    }

    /**
     * {@inheritdoc}
     */
    protected function getMinArguments()
    {
        return 2;
    }

    /**
     * {@inheritdoc}
     */
    protected function getMaxArguments()
    {
        return 2;
    }
}

<?php

namespace Profideo\FormulaInterpreterBundle\Excel\ExpressionLanguage\ExpressionFunction;

use Profideo\FormulaInterpreterBundle\Excel\ExpressionLanguage\ExpressionError;

/**
 * Represents the "ROUND" function that can be used in an expression.
 */
class RoundExpressionFunction extends ExpressionFunction
{
    /**
     * @return string
     */
    protected function getCompilerFunction()
    {
        return sprintf('%s(%s, %s)', $this->getName(), func_get_arg(0), func_get_arg(1));
    }

    /**
     * @return float
     */
    protected function getEvaluatorFunction()
    {
        $args = func_get_args();

        if (! is_numeric($args[1])) {
            throw new ExpressionError(
                sprintf('The function %s expects numeric as parameter 1 but "%s" given', $this->getName(), gettype($args[1]))
            );
        }

        if (! is_int($args[2])) {
            throw new ExpressionError(
                sprintf('The function %s expects integer as parameter 2 but "%s" given', $this->getName(), gettype($args[2]))
            );
        }

        return round($args[1], $args[2], PHP_ROUND_HALF_UP);
    }

    /**
     * {@inheritdoc}
     */
    protected function getMinArguments()
    {
        return 2;
    }

    /**
     * {@inheritdoc}
     */
    protected function getMaxArguments()
    {
        return 2;
    }
}

Add checks for ROUND function
Add checks for ROUND function
