public function calculate($term)
    {
        $tokens = $this->tokenize($term);
        if (sizeof($tokens) == 0) {
            return 0;
        }

        $rootNode = $this->parse($tokens);
        if ($rootNode->isEmpty()) {
            return 0;
        }

        $calculator = $this->container->get('stringcalc_calculator');

        $result = $calculator->calculate($rootNode);

        return $result;
    }
public function calculate($term)
    {
        $tokens = $this->tokenize($term);
        if (sizeof($tokens) == 0) {
            return 0;
        }

        $rootNode = $this->parse($tokens);
        if ($rootNode->isEmpty()) {
            return 0;
        }

        $calculator = $this->container->get('stringcalc_calculator');

        $result = $calculator->calculate($rootNode);

        return $result;
    }
public function calculate ( $ term ) { $ tokens = $ this -> tokenize ( $ term ) ; if ( sizeof ( $ tokens ) == 0 ) { return 0 ; } $ rootNode = $ this -> parse ( $ tokens ) ; if ( $ rootNode -> isEmpty ( ) ) { return 0 ; } $ calculator = $ this -> container -> get ( 'stringcalc_calculator' ) ; $ result = $ calculator -> calculate ( $ rootNode ) ; return $ result ; }
Calculates a term and returns the result.
Will return 0 if there is nothing to calculate.

@param string $term
@return float|int
@throws Exceptions\ContainerException
@throws Exceptions\NotFoundException
Calculates a term and returns the result . Will return 0 if there is nothing to calculate .