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

AbstractQueryBuilder::getField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the jquery-querybuilder-bundle package.
5
 *
6
 * (c) 2017 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
 * Abstract QueryBuilder.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\JQuery\QueryBuilderBundle\API
21
 * @abstract
22
 */
23
abstract class AbstractQueryBuilder implements QueryBuilderInputInterface, QueryBuilderTypeInterface {
24
25
    /**
26
     * Field.
27
     *
28
     * @var string
29
     */
30
    private $field;
31
32
    /**
33
     * Id.
34
     *
35
     * @var string
36
     */
37
    private $id;
38
39
    /**
40
     * Input.
41
     *
42
     * @var string
43
     */
44
    private $input;
45
46
    /**
47
     * Type.
48
     *
49
     * @var string
50
     */
51
    private $type;
52
53
    /**
54
     * Constructor.
55
     */
56
    protected function __construct() {
57
        // NOTHING TO TO.
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63
    public function getField() {
64
        return $this->field;
65
    }
66
67
    /**
68
     * {@inheritDoc}
69
     */
70
    public function getId() {
71
        return $this->id;
72
    }
73
74
    /**
75
     * {@inheritDoc}
76
     */
77
    public function getInput() {
78
        return $this->input;
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84
    public function getType() {
85
        return $this->type;
86
    }
87
88
    /**
89
     * Set the field.
90
     *
91
     * @param string $field The field.
92
     * @return AbstractQueryBuilder Returns this QueryBuilder.
93
     */
94
    public function setField($field) {
95
        $this->field = $field;
96
        return $this;
97
    }
98
99
    /**
100
     * Set the id.
101
     *
102
     * @param string $id The id.
103
     * @return AbstractQueryBuilder Returns this QueryBuilder.
104
     */
105
    public function setId($id) {
106
        $this->id = $id;
107
        return $this;
108
    }
109
110
    /**
111
     * Set the input.
112
     *
113
     * @param string $input The input.
114
     * @return AbstractQueryBuilder Returns this QueryBuilder.
115
     * @throws UnexpectedValueException Throws an unexpected value exception if the input is invalid.
116
     */
117
    public function setInput($input) {
118
        if (false === in_array($input, QueryBuilderEnumerator::enumInputs())) {
119
            throw new UnexpectedValueException(sprintf("The input \"%s\" is invalid", $input));
120
        }
121
        $this->input = $input;
122
        return $this;
123
    }
124
125
    /**
126
     * Set the type.
127
     *
128
     * @param string $type The type.
129
     * @return AbstractQueryBuilder Returns this QueryBuilder.
130
     * @throws UnexpectedValueException Throws an unexpected value exception if the type is invalid.
131
     */
132
    public function setType($type) {
133
        if (null !== $type && false === in_array($type, QueryBuilderEnumerator::enumTypes())) {
134
            throw new UnexpectedValueException(sprintf("The type \"%s\" is invalid", $type));
135
        }
136
        $this->type = $type;
137
        return $this;
138
    }
139
}
140