Passed
Pull Request — master (#18)
by Timon
20:17 queued 12s
created

AbstractQuery::toArray()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 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\RethinkInterface;
8
9
abstract class AbstractQuery implements QueryInterface
10
{
11
    /**
12
     * @var MessageInterface
13
     */
14
    protected $message;
15
16
    /**
17
     * @var RethinkInterface
18
     */
19
    protected $rethink;
20
21
    /**
22
     * @param RethinkInterface $rethink
23
     * @param MessageInterface $message
24
     */
25 13
    public function __construct(RethinkInterface $rethink, MessageInterface $message = null)
26
    {
27 13
        $this->rethink = $rethink;
28 13
        $this->message = $message;
29 13
    }
30
31
    /**
32
     * @return mixed
33
     */
34 13
    public function run()
35
    {
36 13
        $this->message->setQuery($this->toArray());
37
38 13
        return $this->rethink->connection()->run($this->message);
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    abstract public function toArray(): array;
45
}
46