Wrappable   A
last analyzed

Complexity

Total Complexity 25

Size/Duplication

Total Lines 286
Duplicated Lines 0 %

Test Coverage

Coverage 96.15%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 25
eloc 27
c 3
b 0
f 0
dl 0
loc 286
ccs 50
cts 52
cp 0.9615
rs 10

25 Methods

Rating   Name   Duplication   Size   Complexity  
A __clone() 0 3 1
A where() 0 3 1
A andOrderBy() 0 3 1
A orWhere() 0 3 1
A from() 0 3 1
A deleteFrom() 0 3 1
A orderBy() 0 3 1
A bindings() 0 3 1
A update() 0 3 1
A leftJoin() 0 3 1
A orHaving() 0 3 1
A limit() 0 3 1
A innerJoin() 0 3 1
A andHaving() 0 3 1
A sql() 0 3 1
A select() 0 3 1
A table() 0 3 1
A insertInto() 0 3 1
A groupBy() 0 3 1
A having() 0 3 1
A rightJoin() 0 3 1
A __construct() 0 3 1
A andWhere() 0 3 1
A instance() 0 3 1
A type() 0 3 1
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 69
    public function __construct(QueryInterface $query)
36
    {
37 69
        $this->query = $query;
38 69
    }
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 3
    public function bindings()
79
    {
80 3
        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
     * @param  string|null $alias
136
     * @return self
137
     */
138 3
    public function innerJoin($table, $local, $foreign, $alias = null)
139
    {
140 3
        return $this->query->innerJoin($table, $local, $foreign, $alias);
141
    }
142
143
    /**
144
     * Generates an INSERT INTO query.
145
     *
146
     * @param  string $table
147
     * @return \Rougin\Windstorm\InsertInterface
148
     */
149 3
    public function insertInto($table)
150
    {
151 3
        return $this->query->insertInto($table);
152
    }
153
154
    /**
155
     * Returns the instance of the query builder, if any.
156
     *
157
     * @return mixed
158
     */
159 3
    public function instance()
160
    {
161 3
        return $this->query->instance();
162
    }
163
164
    /**
165
     * Generates a LEFT JOIN query.
166
     *
167
     * @param  string      $table
168
     * @param  string      $local
169
     * @param  string      $foreign
170
     * @param  string|null $alias
171
     * @return self
172
     */
173 3
    public function leftJoin($table, $local, $foreign, $alias = null)
174
    {
175 3
        return $this->query->leftJoin($table, $local, $foreign, $alias);
176
    }
177
178
    /**
179
     * Performs a LIMIT query.
180
     *
181
     * @param  integer      $limit
182
     * @param  integer|null $offset
183
     * @return self
184
     */
185 3
    public function limit($limit, $offset = null)
186
    {
187 3
        return $this->query->limit($limit, $offset);
188
    }
189
190
    /**
191
     * Generates an OR HAVING query.
192
     *
193
     * @param  string $key
194
     * @return \Rougin\Windstorm\HavingInterface
195
     */
196 3
    public function orHaving($key)
197
    {
198 3
        return $this->query->orHaving($key);
199
    }
200
201
    /**
202
     * Generates an OR WHERE query.
203
     *
204
     * @param  string $key
205
     * @return \Rougin\Windstorm\WhereInterface
206
     */
207 3
    public function orWhere($key)
208
    {
209 3
        return $this->query->orWhere($key);
210
    }
211
212
    /**
213
     * Generates an ORDER BY query.
214
     *
215
     * @param  string $key
216
     * @return \Rougin\Windstorm\OrderInterface
217
     */
218 3
    public function orderBy($key)
219
    {
220 3
        return $this->query->orderBy($key);
221
    }
222
223
    /**
224
     * Generates a RIGHT JOIN query.
225
     *
226
     * @param  string      $table
227
     * @param  string      $local
228
     * @param  string      $foreign
229
     * @param  string|null $alias
230
     * @return self
231
     */
232 3
    public function rightJoin($table, $local, $foreign, $alias = null)
233
    {
234 3
        return $this->query->rightJoin($table, $local, $foreign, $alias);
235
    }
236
237
    /**
238
     * Generates a SELECT query.
239
     *
240
     * @param  array|string $fields
241
     * @return self
242
     */
243 6
    public function select($fields)
244
    {
245 6
        return $this->query->select($fields);
246
    }
247
248
    /**
249
     * Returns the safe and compiled SQL.
250
     *
251
     * @return string
252
     */
253 3
    public function sql()
254
    {
255 3
        return $this->query->sql();
256
    }
257
258
    /**
259
     * Returns the table name from the query.
260
     *
261
     * @return string
262
     */
263 3
    public function table()
264
    {
265 3
        return $this->query->table();
266
    }
267
268
    /**
269
     * Returns the type of the query.
270
     *
271
     * @return integer
272
     */
273
    public function type()
274
    {
275
        return $this->query->type();
276
    }
277
278
    /**
279
     * Generates an UPDATE query.
280
     *
281
     * @param  string      $table
282
     * @param  string|null $alias
283
     * @return \Rougin\Windstorm\UpdateInterface
284
     */
285 3
    public function update($table, $alias = null)
286
    {
287 3
        return $this->query->update($table, $alias);
288
    }
289
290
    /**
291
     * Generates a WHERE query.
292
     *
293
     * @param  string $key
294
     * @return \Rougin\Windstorm\WhereInterface
295
     */
296 3
    public function where($key)
297
    {
298 3
        return $this->query->where($key);
299
    }
300
}
301