Completed
Push — master ( 3fc573...634850 )
by WEBEWEB
11:27
created

QueryBuilderRule::setValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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 UnexpectedValueException;
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 operator.
75
     *
76
     * @param string $operator The operator.
77
     * @return QueryBuilderRuleInterface Returns this rule.
78
     * @throws UnexpectedValueException Throws an unexpected value exception if the operator is invalid.
79
     */
80
    public function setOperator($operator) {
81
        if (null !== $operator && false === array_key_exists($operator, QueryBuilderEnumerator::enumOperators())) {
82
            throw new UnexpectedValueException(sprintf("The operator \"%s\" is invalid", $operator));
83
        }
84
        $this->operator = $operator;
85
        return $this;
86
    }
87
88
    /**
89
     * Set the value.
90
     *
91
     * @param mixed $value The value.
92
     * @return QueryBuilderRuleInterface Returns this rule.
93
     */
94
    public function setValue($value) {
95
        $this->value = $value;
96
        return $this;
97
    }
98
}
99