Passed
Pull Request — master (#33)
by Marc
05:58
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\Aggregation\AggregationInterface;
10
use TBolier\RethinkQL\Query\Operation\AbstractOperation;
11
use TBolier\RethinkQL\Query\Operation\Get;
12
use TBolier\RethinkQL\RethinkInterface;
13
use TBolier\RethinkQL\Types\Term\TermType;
14
15
class Table extends AbstractOperation implements TableInterface
16
{
17
    /**
18
     * @var array
19
     */
20
    private $query;
21
22
    /**
23
     * @param string $name
24
     * @param RethinkInterface $rethink
25 11
     * @param MessageInterface $message
26
     */
27 11
    public function __construct(string $name, RethinkInterface $rethink, MessageInterface $message)
28
    {
29 11
        parent::__construct($rethink, $message);
30 11
31
        $this->rethink = $rethink;
32 11
        $this->message = $message;
33 11
34
        $this->query = [
35 11
            TermType::TABLE,
36
            [
37
                $name,
38 11
            ],
39
        ];
40
    }
41
42
    /**
43 2
     * @inheritdoc
44
     */
45 2
    public function get($value): AbstractQuery
46
    {
47
        return new Get($this->rethink, $this->message, $this, $value);
48
    }
49
50
    /**
51 11
     * @inheritdoc
52
     */
53 11
    public function limit($value): AggregationInterface
54
    {
55
        return new Limit($this->rethink, $this->message, $this, $value);
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61
    public function orderBy($key): AggregationInterface
62
    {
63
        return new OrderBy($this->rethink, $this->message, $this, $key);
64
    }
65
66
    /**
67
     * @inheritdoc
68
     */
69
    public function toArray(): array
70
    {
71
        return $this->query;
72
    }
73
}
74