Completed
Pull Request — master (#1893)
by
unknown
02:56
created

SortProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setField() 0 4 1
A setOrder() 0 4 1
1
<?php
2
3
namespace Elastica\Processor;
4
5
/**
6
 * Elastica Sort Processor.
7
 *
8
 * @author Federico Panini <[email protected]>
9
 *
10
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-processor.html
11
 */
12
class SortProcessor extends AbstractProcessor
13
{
14
    public const DEFAULT_ORDER_VALUE = 'asc';
15
16
    public function __construct(string $field)
17
    {
18
        $this->setField($field);
19
    }
20
21
    /**
22
     * Set the field.
23
     *
24
     * @return $this
25
     */
26
    public function setField(string $field): self
27
    {
28
        return $this->setParam('field', $field);
29
    }
30
31
    /**
32
     * Set order. Default 'asc'.
33
     *
34
     * @return $this
35
     */
36
    public function setOrder(string $order): self
37
    {
38
        return $this->setParam('order', $order);
39
    }
40
}
41