Andx.php
9 months ago
Base.php
9 months ago
Comparison.php
9 months ago
Composite.php
9 months ago
From.php
9 months ago
Func.php
9 months ago
GroupBy.php
9 months ago
Join.php
9 months ago
Literal.php
9 months ago
Math.php
9 months ago
OrderBy.php
9 months ago
Orx.php
9 months ago
Select.php
9 months ago
index.php
9 months ago
Math.php
43 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Query\Expr; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | class Math |
| 6 | { |
| 7 | protected $leftExpr; |
| 8 | protected $operator; |
| 9 | protected $rightExpr; |
| 10 | public function __construct($leftExpr, $operator, $rightExpr) |
| 11 | { |
| 12 | $this->leftExpr = $leftExpr; |
| 13 | $this->operator = $operator; |
| 14 | $this->rightExpr = $rightExpr; |
| 15 | } |
| 16 | public function getLeftExpr() |
| 17 | { |
| 18 | return $this->leftExpr; |
| 19 | } |
| 20 | public function getOperator() |
| 21 | { |
| 22 | return $this->operator; |
| 23 | } |
| 24 | public function getRightExpr() |
| 25 | { |
| 26 | return $this->rightExpr; |
| 27 | } |
| 28 | public function __toString() |
| 29 | { |
| 30 | // Adjusting Left Expression |
| 31 | $leftExpr = (string) $this->leftExpr; |
| 32 | if ($this->leftExpr instanceof Math) { |
| 33 | $leftExpr = '(' . $leftExpr . ')'; |
| 34 | } |
| 35 | // Adjusting Right Expression |
| 36 | $rightExpr = (string) $this->rightExpr; |
| 37 | if ($this->rightExpr instanceof Math) { |
| 38 | $rightExpr = '(' . $rightExpr . ')'; |
| 39 | } |
| 40 | return $leftExpr . ' ' . $this->operator . ' ' . $rightExpr; |
| 41 | } |
| 42 | } |
| 43 |