Passed
Push — main ( ae29e3...10579d )
by Sammy
07:25
created

OrderBy::asc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace HexMakina\Crudites\Grammar\Clause;
4
5
use HexMakina\Crudites\Grammar\DeckOrderBy;
6
7
class OrderBy extends Clause
8
{
9
    private DeckOrderBy $deck;
10
11
    public function __construct($selected, string $direction)
12
    {
13
        $this->deck = new DeckOrderBy($selected, $direction);
14
    }
15
16
    public function add(...$args): self
17
    {
18
        list($selected, $direction) = $args;
19
        $this->deck->add($selected, $direction);
20
        return $this;
21
    }
22
23
    public function asc($selected): self
24
    {
25
        return $this->add([$selected, 'ASC']);
26
    }
27
28
    public function desc($selected): self
29
    {
30
        return $this->add([$selected, 'DESC']);
31
    }
32
33
    public function __toString(): string
34
    {
35
        return 'ORDER BY ' . $this->deck;
36
    }
37
38
39
    public function name(): string
40
    {
41
        return self::ORDER;
42
    }
43
}
44