Passed
Pull Request — master (#18)
by Timon
11:18 queued 57s
created

AbstractQuery   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 37
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

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