Ordening   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 13
c 1
b 0
f 0
dl 0
loc 41
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A toArray() 0 3 1
A desc() 0 10 1
A asc() 0 10 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\Query;
5
6
use TBolier\RethinkQL\RethinkInterface;
7
use TBolier\RethinkQL\Types\Term\TermType;
8
9
class Ordening extends AbstractQuery
10
{
11
    /**
12
     * @var array
13
     */
14
    private $query;
15
16
    public function __construct(string $key, RethinkInterface $rethink)
17
    {
18
        parent::__construct($rethink);
19
20
        $this->asc($key);
21
    }
22
23
    public function asc(string $key): Ordening
24
    {
25
        $this->query = [
26
            TermType::ASC,
27
            [
28
                $key,
29
            ],
30
        ];
31
32
        return $this;
33
    }
34
35
    public function desc(string $key): Ordening
36
    {
37
        $this->query = [
38
            TermType::DESC,
39
            [
40
                $key,
41
            ],
42
        ];
43
44
        return $this;
45
    }
46
47
    public function toArray(): array
48
    {
49
        return $this->query;
50
    }
51
}
52