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
OrderBy.php
38 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Query\Expr; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use function count; |
| 6 | use function implode; |
| 7 | class OrderBy |
| 8 | { |
| 9 | protected $preSeparator = ''; |
| 10 | protected $separator = ', '; |
| 11 | protected $postSeparator = ''; |
| 12 | protected $allowedClasses = []; |
| 13 | protected $parts = []; |
| 14 | public function __construct($sort = null, $order = null) |
| 15 | { |
| 16 | if ($sort) { |
| 17 | $this->add($sort, $order); |
| 18 | } |
| 19 | } |
| 20 | public function add($sort, $order = null) |
| 21 | { |
| 22 | $order = !$order ? 'ASC' : $order; |
| 23 | $this->parts[] = $sort . ' ' . $order; |
| 24 | } |
| 25 | public function count() |
| 26 | { |
| 27 | return count($this->parts); |
| 28 | } |
| 29 | public function getParts() |
| 30 | { |
| 31 | return $this->parts; |
| 32 | } |
| 33 | public function __toString() |
| 34 | { |
| 35 | return $this->preSeparator . implode($this->separator, $this->parts) . $this->postSeparator; |
| 36 | } |
| 37 | } |
| 38 |