GDS\Mapper\ProtoBufGQLParser::recordOrder PHP Method

recordOrder() private method

Process the ORDER BY clause
private recordOrder ( $arr ) : string
$arr
return string
    private function recordOrder($arr)
    {
        $arr_order_bys = explode(',', $arr['order']);
        foreach ($arr_order_bys as $str_order_by) {
            $arr_matches = [];
            preg_match('/\\s?(?<field>[^\\s]*)\\s*(?<dir>ASC|DESC)?/i', $str_order_by, $arr_matches);
            if (isset($arr_matches['field'])) {
                $str_direction = strtoupper(isset($arr_matches['dir']) ? $arr_matches['dir'] : 'ASC');
                if (isset($this->arr_directions[$str_direction])) {
                    $int_direction = $this->arr_directions[$str_direction];
                } else {
                    throw new GQL("Unsupported direction in ORDER BY: [{$arr_matches['dir']}] [{$str_order_by}]");
                }
                $this->arr_order_bys[] = ['property' => $this->lookupToken($arr_matches['field']), 'direction' => $int_direction];
            }
        }
        return '';
    }