Passed
Push — master ( 694425...cb2fe4 )
by Marc
03:56
created

Ordening::desc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\Query;
5
6
use TBolier\RethinkQL\Message\MessageInterface;
7
use TBolier\RethinkQL\RethinkInterface;
8
use TBolier\RethinkQL\Types\Term\TermType;
9
10
class Ordening extends AbstractQuery implements OrdeningInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    private $query;
16
17
    /**
18
     * @param string $key
19
     * @param RethinkInterface $rethink
20
     * @param MessageInterface $message
21
     */
22
    public function __construct(string $key, RethinkInterface $rethink, MessageInterface $message)
23
    {
24
        parent::__construct($rethink, $message);
25
26
        $this->asc($key);
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function asc(string $key): OrdeningInterface
33
    {
34
        $this->query = [
35
            TermType::ASC,
36
            [
37
                $key,
38
            ],
39
        ];
40
41
        return $this;
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function desc(string $key): OrdeningInterface
48
    {
49
        $this->query = [
50
            TermType::DESC,
51
            [
52
                $key,
53
            ],
54
        ];
55
56
        return $this;
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62
    public function toArray(): array
63
    {
64
        return $this->query;
65
    }
66
}
67