Passed
Push — master ( 9f58b4...83392d )
by Rougin
03:13
created

Wrappable::andHaving()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Rougin\Windstorm\Relation;
4
5
use Rougin\Windstorm\QueryInterface;
6
7
/**
8
 * Wrappable
9
 *
10
 * @package Windstorm
11
 * @author  Rougin Gutib <[email protected]>
12
 */
13
class Wrappable implements QueryInterface
14
{
15
    /**
16
     * @var \Rougin\Windstorm\QueryInterface
17
     */
18
    protected $query;
19
20
    /**
21
     * Clones the builder instance.
22
     *
23
     * @return void
24
     */
25 3
    public function __clone()
26
    {
27 3
        $this->query = clone $this->query;
28 3
    }
29
30
    /**
31
     * Initializes the wrappable instance.
32
     *
33
     * @param \Rougin\Windstorm\QueryInterface $query
34
     */
35 75
    public function __construct(QueryInterface $query)
36
    {
37 75
        $this->query = $query;
38 75
    }
39
40
    /**
41
     * Generates an AND HAVING query.
42
     *
43
     * @param  string $key
44
     * @return \Rougin\Windstorm\HavingInterface
45
     */
46 3
    public function andHaving($key)
47
    {
48 3
        return $this->query->andHaving($key);
49
    }
50
51
    /**
52
     * Generates a multiple ORDER BY query.
53
     *
54
     * @param  string $key
55
     * @return \Rougin\Windstorm\OrderInterface
56
     */
57 3
    public function andOrderBy($key)
58
    {
59 3
        return $this->query->andOrderBy($key);
60
    }
61
62
    /**
63
     * Generates an AND WHERE query.
64
     *
65
     * @param  string $key
66
     * @return \Rougin\Windstorm\WhereInterface
67
     */
68 3
    public function andWhere($key)
69
    {
70 3
        return $this->query->andWhere($key);
71
    }
72
73
    /**
74
     * Returns the SQL bindings specified.
75
     *
76
     * @return array
77
     */
78 9
    public function bindings()
79
    {
80 9
        return $this->query->bindings();
81
    }
82
83
    /**
84
     * Generates a DELETE FROM query.
85
     *
86
     * @param  string      $table
87
     * @param  string|null $alias
88
     * @return self
89
     */
90 3
    public function deleteFrom($table, $alias = null)
91
    {
92 3
        return $this->query->deleteFrom($table, $alias);
93
    }
94
95
    /**
96
     * Generates a FROM query.
97
     *
98
     * @param  string      $table
99
     * @param  string|null $alias
100
     * @return self
101
     */
102 3
    public function from($table, $alias = null)
103
    {
104 3
        return $this->query->from($table, $alias);
105
    }
106
107
    /**
108
     * Generates a GROUP BY query.
109
     *
110
     * @param  array|string $fields
111
     * @return self
112
     */
113 3
    public function groupBy($fields)
114
    {
115 3
        return $this->query->groupBy($fields);
116
    }
117
118
    /**
119
     * Generates a HAVING query.
120
     *
121
     * @param  string $key
122
     * @return \Rougin\Windstorm\HavingInterface
123
     */
124 3
    public function having($key)
125
    {
126 3
        return $this->query->having($key);
127
    }
128
129
    /**
130
     * Generates an INNER JOIN query.
131
     *
132
     * @param  string $table
133
     * @param  string $local
134
     * @param  string $foreign
135
     * @return self
136
     */
137 3
    public function innerJoin($table, $local, $foreign)
138
    {
139 3
        return $this->query->innerJoin($table, $local, $foreign);
140
    }
141
142
    /**
143
     * Generates an INSERT INTO query.
144
     *
145
     * @param  string $table
146
     * @return \Rougin\Windstorm\InsertInterface
147
     */
148 3
    public function insertInto($table)
149
    {
150 3
        return $this->query->insertInto($table);
151
    }
152
153
    /**
154
     * Returns the instance of the query builder, if any.
155
     *
156
     * @return mixed
157
     */
158 3
    public function instance()
159
    {
160 3
        return $this->query->instance();
161
    }
162
163
    /**
164
     * Generates a LEFT JOIN query.
165
     *
166
     * @param  string $table
167
     * @param  string $local
168
     * @param  string $foreign
169
     * @return self
170
     */
171 3
    public function leftJoin($table, $local, $foreign)
172
    {
173 3
        return $this->query->leftJoin($table, $local, $foreign);
174
    }
175
176
    /**
177
     * Performs a LIMIT query.
178
     *
179
     * @param  integer      $limit
180
     * @param  integer|null $offset
181
     * @return self
182
     */
183 3
    public function limit($limit, $offset = null)
184
    {
185 3
        return $this->query->limit($limit, $offset);
186
    }
187
188
    /**
189
     * Generates an OR HAVING query.
190
     *
191
     * @param  string $key
192
     * @return \Rougin\Windstorm\HavingInterface
193
     */
194 3
    public function orHaving($key)
195
    {
196 3
        return $this->query->orHaving($key);
197
    }
198
199
    /**
200
     * Generates an OR WHERE query.
201
     *
202
     * @param  string $key
203
     * @return \Rougin\Windstorm\WhereInterface
204
     */
205 3
    public function orWhere($key)
206
    {
207 3
        return $this->query->orWhere($key);
208
    }
209
210
    /**
211
     * Generates an ORDER BY query.
212
     *
213
     * @param  string $key
214
     * @return \Rougin\Windstorm\OrderInterface
215
     */
216 3
    public function orderBy($key)
217
    {
218 3
        return $this->query->orderBy($key);
219
    }
220
221
    /**
222
     * Generates a RIGHT JOIN query.
223
     *
224
     * @param  string $table
225
     * @param  string $local
226
     * @param  string $foreign
227
     * @return self
228
     */
229 3
    public function rightJoin($table, $local, $foreign)
230
    {
231 3
        return $this->query->rightJoin($table, $local, $foreign);
232
    }
233
234
    /**
235
     * Generates a SELECT query.
236
     *
237
     * @param  array|string $fields
238
     * @return self
239
     */
240 6
    public function select($fields)
241
    {
242 6
        return $this->query->select($fields);
243
    }
244
245
    /**
246
     * Returns the safe and compiled SQL.
247
     *
248
     * @return string
249
     */
250 9
    public function sql()
251
    {
252 9
        return $this->query->sql();
253
    }
254
255
    /**
256
     * Returns the table name from the query.
257
     *
258
     * @return string
259
     */
260 3
    public function table()
261
    {
262 3
        return $this->query->table();
263
    }
264
265
    /**
266
     * Returns the type of the query.
267
     *
268
     * @return integer
269
     */
270 6
    public function type()
271
    {
272 6
        return $this->query->type();
273
    }
274
275
    /**
276
     * Generates an UPDATE query.
277
     *
278
     * @param  string      $table
279
     * @param  string|null $alias
280
     * @return \Rougin\Windstorm\UpdateInterface
281
     */
282 3
    public function update($table, $alias = null)
283
    {
284 3
        return $this->query->update($table, $alias);
285
    }
286
287
    /**
288
     * Generates a WHERE query.
289
     *
290
     * @param  string $key
291
     * @return \Rougin\Windstorm\WhereInterface
292
     */
293 3
    public function where($key)
294
    {
295 3
        return $this->query->where($key);
296
    }
297
}
298