Completed
Push — master ( 9e840a...7acab3 )
by Nicolas
03:27
created

Terms::setOrders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Elastica\Aggregation;
3
4
/**
5
 * Class Terms.
6
 *
7
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
8
 */
9
class Terms extends AbstractTermsAggregation
10
{
11
    /**
12
     * Set the bucket sort order.
13
     *
14
     * @param string $order     "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
15
     * @param string $direction "asc" or "desc"
16
     *
17
     * @return $this
18
     */
19
    public function setOrder($order, $direction)
20
    {
21
        return $this->setParam('order', [$order => $direction]);
22
    }
23
24
    /**
25
     * Sets a list of bucket sort orders.
26
     *
27
     * @param array $orders A list of [<aggregationField>|"_count"|"_term" => <direction>] definitions.
28
     *
29
     * @return $this
30
     */
31
    public function setOrders(array $orders)
32
    {
33
        return $this->setParam('order', $orders);
34
    }
35
}
36