4 * Structural class representing one item in an order vector.
6 * See @{class:PhabricatorQueryOrderVector} for discussion of order vectors.
7 * This represents one item in an order vector, like "id". When combined with
8 * the other items in the vector, a complete ordering (like "name, id") is
11 * Construct an item using @{method:newFromScalar}:
13 * $item = PhabricatorQueryOrderItem::newFromScalar('id');
15 * This class is primarily internal to the query infrastructure, and most
16 * application code should not need to interact with it directly.
18 final class PhabricatorQueryOrderItem
extends Phobject
{
23 private function __construct() {
27 public static function newFromScalar($scalar) {
28 // If the string is something like "-id", strip the "-" off and mark it
31 if (!strncmp($scalar, '-', 1)) {
33 $scalar = substr($scalar, 1);
36 $item = new PhabricatorQueryOrderItem();
37 $item->orderKey
= $scalar;
38 $item->isReversed
= $is_reversed;
43 public function getIsReversed() {
44 return $this->isReversed
;
47 public function getOrderKey() {
48 return $this->orderKey
;
51 public function getAsScalar() {
52 if ($this->getIsReversed()) {
58 return $prefix.$this->getOrderKey();