Passed
Pull Request — master (#18)
by Marc
02:43
created

Table::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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