public function evaluate() { if (is_array($result = parent::evaluate())) { throw new ParsingException('exp accept only one argument'); } return (double) exp($result); }
public function evaluate() { $result = parent::evaluate(); if (!is_array($result) || count($result) !== 3) { throw new ParsingException('If must have 3 arguments, ex: if(a > 2, 1, 2)'); } return $result[0] ? $result[1] : $result[2]; }
public function evaluate() { $result = parent::evaluate(); if (!is_array($result)) { return $result; } return array_sum($result); }
public function evaluate() { $result = parent::evaluate(); if (!is_array($result) || count($result) !== 2) { throw new ParsingException('Power must have 2 arguments, ex: power(10,2)'); } return pow($result[0], $result[1]); }
public function evaluate() { $result = parent::evaluate(); if (!is_array($result) || empty($result)) { return $result; } $count = count($result); return array_sum($result) / $count; }
public function evaluate() { $result = parent::evaluate(); if (is_array($result)) { if (count($result) != 2) { throw new ParsingException('Log accepts only 2 arguments'); } return log($result[0], $result[1]); } else { $content = (string) $this->content; if ($content == 'log(') { return log10(parent::evaluate()); } else { // ln return log(parent::evaluate()); } } }
public function evaluate() { return tan(deg2rad(parent::evaluate())); }
public function evaluate() { return sqrt(parent::evaluate()); }