. */ namespace Doctrine\ORM\Query\Expr; /** * Expression class for DQL math statements * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.org * @since 2.0 * @version $Revision$ * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel */ class Math { private $_leftExpr; private $_operator; private $_rightExpr; public function __construct($leftExpr, $operator, $rightExpr) { $this->_leftExpr = $leftExpr; $this->_operator = $operator; $this->_rightExpr = $rightExpr; } public function __toString() { // Adjusting Left Expression $leftExpr = (string) $this->_leftExpr; if ($this->_leftExpr instanceof Math) { $leftExpr = '(' . $leftExpr . ')'; } // Adjusting Right Expression $rightExpr = (string) $this->_rightExpr; if ($this->_rightExpr instanceof Math) { $rightExpr = '(' . $rightExpr . ')'; } return $leftExpr . ' ' . $this->_operator . ' ' . $rightExpr; } }