Passed
Pull Request — master (#18)
by Marc
03:37
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\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