Limit   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 9 1
A __construct() 0 10 1
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