CompositeCompare   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 95.24%

Importance

Changes 0
Metric Value
wmc 10
eloc 18
dl 0
loc 74
c 0
b 0
f 0
ccs 20
cts 21
cp 0.9524
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getComparator() 0 3 1
A update() 0 2 1
A getRight() 0 3 1
A __construct() 0 6 1
A getLeft() 0 7 3
A accept() 0 8 3
1
<?php
2
3
namespace Xsolve\SalesforceClient\QueryBuilder\Expr\Compare;
4
5
use Xsolve\SalesforceClient\QueryBuilder\Expr\ExprInterface;
6
use Xsolve\SalesforceClient\QueryBuilder\Visitor\VisiteeInterface;
7
use Xsolve\SalesforceClient\QueryBuilder\Visitor\VisitorInterface;
8
9
class CompositeCompare extends AbstractCompare implements ExprInterface, VisiteeInterface
10
{
11
    /**
12
     * @var AbstractCompare
13
     */
14
    private $leftExpr;
15
16
    /**
17
     * @var Operator
18
     */
19
    private $operator;
20
21
    /**
22
     * @var AbstractCompare
23
     */
24
    private $rightExpr;
25
26
    /**
27
     * @var bool
28
     */
29
    private $wrapPrevious;
30
31 1
    public function __construct(AbstractCompare $leftExpr, Operator $operator, AbstractCompare $rightExpr, bool $wrapPrevious = false)
32
    {
33 1
        $this->leftExpr = $leftExpr;
34 1
        $this->operator = $operator;
35 1
        $this->rightExpr = $rightExpr;
36 1
        $this->wrapPrevious = $wrapPrevious;
37 1
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 1
    public function getComparator(): string
43
    {
44 1
        return $this->operator->value();
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 1
    public function getLeft(): string
51
    {
52 1
        if ($this->wrapPrevious && $this->leftExpr instanceof self) {
53 1
            return sprintf('(%s)', $this->leftExpr->asSOQL());
54
        }
55
56 1
        return $this->leftExpr->asSOQL();
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 1
    public function getRight(): string
63
    {
64 1
        return $this->rightExpr->asSOQL();
65
    }
66
67 1
    public function accept(VisitorInterface $visitor)
68
    {
69 1
        if ($this->leftExpr instanceof VisiteeInterface) {
70 1
            $this->leftExpr->accept($visitor);
71
        }
72
73 1
        if ($this->rightExpr instanceof VisiteeInterface) {
74 1
            $this->rightExpr->accept($visitor);
75
        }
76 1
    }
77
78
    /**
79
     * Inner expressions will be updated by reference.
80
     */
81
    public function update(array $values)
82
    {
83
    }
84
}
85