Limit::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\Query\Transformation;
5
6
use TBolier\RethinkQL\Query\AbstractQuery;
7
use TBolier\RethinkQL\Query\Aggregation\AggregationTrait;
8
use TBolier\RethinkQL\Query\Operation\OperationTrait;
9
use TBolier\RethinkQL\Query\QueryInterface;
10
use TBolier\RethinkQL\RethinkInterface;
11
use TBolier\RethinkQL\Types\Term\TermType;
12
13
class Limit extends AbstractQuery
14
{
15
    use AggregationTrait;
16
    use OperationTrait;
17
    use TransformationTrait;
18
19
    /**
20
     * @var int
21
     */
22
    private $n;
23
24
    /**
25
     * @var QueryInterface
26
     */
27
    private $query;
28
29
    public function __construct(
30
        RethinkInterface $rethink,
31
        QueryInterface $query,
32
        int $n
33
    ) {
34
        parent::__construct($rethink);
35
36
        $this->query = $query;
37
        $this->n = $n;
38
        $this->rethink = $rethink;
39
    }
40
41
    public function toArray(): array
42
    {
43
        return [
44
            TermType::LIMIT,
45
            [
46
                $this->query->toArray(),
47
                [
48
                    TermType::DATUM,
49
                    $this->n,
50
                ],
51
            ],
52
        ];
53
    }
54
}
55