Ordening::asc()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 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