SortNode   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getNodeName() 0 4 1
A addField() 0 4 1
A getFields() 0 4 1
1
<?php
2
namespace Xiag\Rql\Parser\Node;
3
4
use Xiag\Rql\Parser\AbstractNode;
5
6
/**
7
 * @codeCoverageIgnore
8
 */
9
class SortNode extends AbstractNode
10
{
11
    const SORT_ASC = 1;
12
    const SORT_DESC = -1;
13
14
    /**
15
     * @var array
16
     */
17
    protected $fields;
18
19
    /**
20
     * @param array $fields
21
     */
22
    public function __construct(array $fields = [])
23
    {
24
        $this->fields = $fields;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function getNodeName()
31
    {
32
        return 'sort';
33
    }
34
35
    /**
36
     * @param string $field
37
     * @param int $direction
38
     * @return void
39
     */
40
    public function addField($field, $direction = self::SORT_ASC)
41
    {
42
        $this->fields[$field] = $direction;
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getFields()
49
    {
50
        return $this->fields;
51
    }
52
}
53