Passed
Pull Request — master (#31)
by Marc
03:30
created

Table::limit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
ccs 1
cts 1
cp 1
cc 1
eloc 1
nc 1
nop 1
crap 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\Query\Aggregation\Limit;
8
use TBolier\RethinkQL\Query\Aggregation\OrderBy;
9
use TBolier\RethinkQL\Query\Operation\AbstractOperation;
10
use TBolier\RethinkQL\Query\Operation\Get;
11
use TBolier\RethinkQL\RethinkInterface;
12
use TBolier\RethinkQL\Types\Term\TermType;
13
14
class Table extends AbstractOperation implements TableInterface
15
{
16
    /**
17
     * @var array
18
     */
19
    private $query;
20
21
    /**
22
     * @param string $name
23
     * @param RethinkInterface $rethink
24
     * @param MessageInterface $message
25 11
     */
26
    public function __construct(string $name, RethinkInterface $rethink, MessageInterface $message)
27 11
    {
28
        parent::__construct($rethink, $message);
29 11
30 11
        $this->rethink = $rethink;
31
        $this->message = $message;
32 11
33 11
        $this->query = [
34
            TermType::TABLE,
35 11
            [
36
                $name,
37
            ],
38 11
        ];
39
    }
40
41
    /**
42
     * @inheritdoc
43 2
     */
44
    public function get($value): QueryInterface
45 2
    {
46
        return new Get($this->rethink, $this->message, $this, $value);
47
    }
48
49
    /**
50
     * @inheritdoc
51 11
     */
52
    public function limit($value): QueryInterface
53 11
    {
54
        return new Limit($this->rethink, $this->message, $this, $value);
55
    }
56
57
    /**
58
     * @inheritdoc
59
     */
60
    public function orderBy($value): QueryInterface
61
    {
62
        return new OrderBy($this->rethink, $this->message, $this, $value);
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68
    public function toArray(): array
69
    {
70
        return $this->query;
71
    }
72
}
73