Completed
Push — master ( 34e4c2...2aa783 )
by WEBEWEB
01:18
created

QueryBuilderRule   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 88
c 0
b 0
f 0
wmc 9
lcom 1
cbo 2
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getDecorator() 0 3 1
A getOperator() 0 3 1
A getValue() 0 3 1
A setDecorator() 0 4 1
A setOperator() 0 7 3
A setValue() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the jquery-querybuilder-bundle package.
5
 *
6
 * (c) 2019 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\JQuery\QueryBuilderBundle\API;
13
14
use InvalidArgumentException;
15
16
/**
17
 * QueryBuilder rule.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\JQuery\QueryBuilderBundle\API
21
 */
22
class QueryBuilderRule extends AbstractQueryBuilder implements QueryBuilderOperatorInterface, QueryBuilderRuleInterface {
23
24
    /**
25
     * Decorator.
26
     *
27
     * @var QueryBuilderDecoratorInterface
28
     */
29
    private $decorator;
30
31
    /**
32
     * Operator.
33
     *
34
     * @var string
35
     */
36
    private $operator;
37
38
    /**
39
     * Value.
40
     *
41
     * @var mixed
42
     */
43
    private $value;
44
45
    /**
46
     * Constructor.
47
     */
48
    public function __construct() {
49
        parent::__construct();
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function getDecorator() {
56
        return $this->decorator;
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62
    public function getOperator() {
63
        return $this->operator;
64
    }
65
66
    /**
67
     * {@inheritDoc}
68
     */
69
    public function getValue() {
70
        return $this->value;
71
    }
72
73
    /**
74
     * Set the decorator.
75
     *
76
     * @param QueryBuilderDecoratorInterface|null $decorator The decorator.
77
     * @return QueryBuilderRuleInterface Returns this rule.
78
     */
79
    public function setDecorator(QueryBuilderDecoratorInterface $decorator = null) {
80
        $this->decorator = $decorator;
81
        return $this;
82
    }
83
84
    /**
85
     * Set the operator.
86
     *
87
     * @param string $operator The operator.
88
     * @return QueryBuilderRuleInterface Returns this rule.
89
     * @throws InvalidArgumentException Throws an invalid argument exception if the operator is invalid.
90
     */
91
    public function setOperator($operator) {
92
        if (null !== $operator && false === array_key_exists($operator, QueryBuilderEnumerator::enumOperators())) {
93
            throw new InvalidArgumentException(sprintf("The operator \"%s\" is invalid", $operator));
94
        }
95
        $this->operator = $operator;
96
        return $this;
97
    }
98
99
    /**
100
     * Set the value.
101
     *
102
     * @param mixed $value The value.
103
     * @return QueryBuilderRuleInterface Returns this rule.
104
     */
105
    public function setValue($value) {
106
        $this->value = $value;
107
        return $this;
108
    }
109
}
110