Passed
Pull Request — master (#18)
by Marc
03:37
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\RethinkInterface;
7
8
abstract class AbstractQuery implements QueryInterface
9
{
10
    /**
11
     * @var MessageInterface
12
     */
13
    protected $message;
14
15
    /**
16
     * @var RethinkInterface
17
     */
18
    protected $rethink;
19
20
    /**
21
     * @param RethinkInterface $rethink
22
     * @param MessageInterface $message
23
     */
24 13
    public function __construct(RethinkInterface $rethink, MessageInterface $message = null)
25
    {
26 13
        $this->rethink = $rethink;
27 13
        $this->message = $message;
28 13
    }
29
30
    /**
31
     * @return mixed
32
     */
33 13
    public function run()
34
    {
35 13
        $this->message->setQuery($this->toArray());
36
37 13
        return $this->rethink->connection()->run($this->message);
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    abstract public function toArray(): array;
44
}
45