diff -r 000000000000 -r 7f95f8617b0b vendor/doctrine/lib/Doctrine/ORM/Query/Expr/Math.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/doctrine/lib/Doctrine/ORM/Query/Expr/Math.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,66 @@ +. + */ + +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; + } +} \ No newline at end of file