Passed
Push — master ( 139da0...112cee )
by Michel
03:17
created

AndLogic   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A toArray() 0 8 1
1
<?php
2
3
namespace TBolier\RethinkQL\Query\Logic;
4
5
use TBolier\RethinkQL\Message\MessageInterface;
6
use TBolier\RethinkQL\Query\Operation\AbstractOperation;
7
use TBolier\RethinkQL\Query\QueryInterface;
8
use TBolier\RethinkQL\RethinkInterface;
9
use TBolier\RethinkQL\Types\Term\TermType;
10
11
class AndLogic extends AbstractOperation
12
{
13
    /**
14
     * @var QueryInterface
15
     */
16
    private $functionOne;
17
18
    /**
19
     * @var QueryInterface
20
     */
21
    private $functionTwo;
22
23
    /**
24
     * @param RethinkInterface $rethink
25
     * @param MessageInterface $message
26
     * @param QueryInterface $functionOne
27
     * @param QueryInterface $functionTwo
28
     */
29
    public function __construct(
30
        RethinkInterface $rethink,
31
        MessageInterface $message,
32
        QueryInterface $functionOne,
33
        QueryInterface $functionTwo
34
    ) {
35
        parent::__construct($rethink, $message);
36
37
        $this->rethink = $rethink;
38
        $this->message = $message;
39
        $this->functionOne = $functionOne;
40
        $this->functionTwo = $functionTwo;
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    public function toArray(): array
47
    {
48
        return
49
            [
50
                TermType::AND,
51
                [
52
                    $this->functionOne->toArray(),
53
                    $this->functionTwo->toArray(),
54
                ],
55
            ];
56
    }
57
}
58