Path: blob/master/src/infrastructure/query/order/PhabricatorQueryOrderItem.php
12242 views
<?php12/**3* Structural class representing one item in an order vector.4*5* See @{class:PhabricatorQueryOrderVector} for discussion of order vectors.6* This represents one item in an order vector, like "id". When combined with7* the other items in the vector, a complete ordering (like "name, id") is8* described.9*10* Construct an item using @{method:newFromScalar}:11*12* $item = PhabricatorQueryOrderItem::newFromScalar('id');13*14* This class is primarily internal to the query infrastructure, and most15* application code should not need to interact with it directly.16*/17final class PhabricatorQueryOrderItem extends Phobject {1819private $orderKey;20private $isReversed;2122private function __construct() {23// <private>24}2526public static function newFromScalar($scalar) {27// If the string is something like "-id", strip the "-" off and mark it28// as reversed.29$is_reversed = false;30if (!strncmp($scalar, '-', 1)) {31$is_reversed = true;32$scalar = substr($scalar, 1);33}3435$item = new PhabricatorQueryOrderItem();36$item->orderKey = $scalar;37$item->isReversed = $is_reversed;3839return $item;40}4142public function getIsReversed() {43return $this->isReversed;44}4546public function getOrderKey() {47return $this->orderKey;48}4950public function getAsScalar() {51if ($this->getIsReversed()) {52$prefix = '-';53} else {54$prefix = '';55}5657return $prefix.$this->getOrderKey();58}5960}616263