Passed
Push — next ( f287d6...dbfc9f )
by Bas
12:00
created

CompilesWhereClauses   A

Complexity

Total Complexity 38

Size/Duplication

Total Lines 571
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 38
eloc 180
c 3
b 0
f 0
dl 0
loc 571
ccs 195
cts 208
cp 0.9375
rs 9.36

29 Methods

Rating   Name   Duplication   Size   Complexity  
A compileWheres() 0 13 3
A whereBasic() 0 12 1
A whereExists() 0 10 1
A whereNested() 0 9 1
A whereTime() 0 12 1
A compileWheresToArray() 0 5 1
A whereYear() 0 12 1
A whereNotInRaw() 0 9 1
A whereInRaw() 0 10 1
A whereDay() 0 12 1
A normalizeOperator() 0 10 3
A parameter() 0 3 2
A whereSub() 0 12 1
A isExpression() 0 3 1
A whereNotNull() 0 10 1
A whereNull() 0 10 1
A whereJsonLength() 0 14 1
A whereNotExists() 0 10 1
A whereJsonContains() 0 12 2
A whereIn() 0 10 1
A getBetweenOperators() 0 13 2
A whereDate() 0 12 1
A translateOperator() 0 7 2
A whereBetween() 0 21 1
A whereMonth() 0 12 1
A whereColumn() 0 12 1
A whereNotIn() 0 10 1
A whereBetweenColumns() 0 19 1
A getOperatorByWhereType() 0 7 2
1
<?php
2
3
namespace LaravelFreelancerNL\Aranguent\Query\Concerns;
4
5
use Illuminate\Database\Query\Builder as IluminateBuilder;
6
use Illuminate\Database\Query\Expression;
7
use LaravelFreelancerNL\Aranguent\Query\Builder;
8
use LaravelFreelancerNL\FluentAQL\Exceptions\BindException;
9
10
trait CompilesWhereClauses
11
{
12
    /**
13
     * Compile the "where" portions of the query.
14
     *
15
     * @param Builder $builder
16
     * @param array<mixed> $wheres
17
     * @param string $source
18
     * @return Builder
19
     *
20
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
21
     */
22 161
    protected function compileWheres(Builder $builder, array $wheres = [], string $source = 'wheres'): Builder
23
    {
24 161
        if (is_null($builder->$source)) {
25
            return $builder;
26
        }
27
28 161
        $predicates = $this->compileWheresToArray($builder, $source);
29
30 161
        if (count($predicates) > 0) {
31 109
            $builder->aqb = $builder->aqb->filter($predicates);
0 ignored issues
show
Bug introduced by
The method filter() does not exist on LaravelFreelancerNL\Flue...ions\FunctionExpression. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
            /** @scrutinizer ignore-call */ 
32
            $builder->aqb = $builder->aqb->filter($predicates);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
        }
33
34 161
        return $builder;
35
    }
36
37
    /**
38
     * Get an array of all the where clauses for the query.
39
     *
40
     * @param Builder $builder
41
     * @param string $source
42
     * @return array<mixed>
43
     */
44 161
    protected function compileWheresToArray(Builder $builder, string $source = 'wheres'): array
45
    {
46 161
        return collect($builder->$source)->map(function ($where) use ($builder) {
47 109
            return $this->{"where{$where['type']}"}($builder, $where);
48 161
        })->all();
49
    }
50
51
    protected function getOperatorByWhereType($type)
52
    {
53
        if (isset($this->whereTypeOperators[$type])) {
54
            return $this->whereTypeOperators[$type];
55
        }
56
57
        return '==';
58
    }
59
60
    /**
61
     * Determine if the given value is a raw expression.
62
     *
63
     * @param  mixed  $value
64
     * @return bool
65
     */
66 94
    public function isExpression($value)
67
    {
68 94
        return $value instanceof Expression;
69
    }
70
71
    /**
72
     * Get the appropriate query parameter place-holder for a value.
73
     *
74
     * @param  Builder  $query
75
     * @param  mixed  $value
76
     * @return object
77
     */
78 94
    public function parameter(Builder $query, $value)
79
    {
80 94
        return $this->isExpression($value) ? $this->getValue($value) : $query->aqb->bind($value);
0 ignored issues
show
Bug introduced by
It seems like getValue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

80
        return $this->isExpression($value) ? $this->/** @scrutinizer ignore-call */ getValue($value) : $query->aqb->bind($value);
Loading history...
Bug introduced by
The method bind() does not exist on LaravelFreelancerNL\Flue...ions\FunctionExpression. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

80
        return $this->isExpression($value) ? $this->getValue($value) : $query->aqb->/** @scrutinizer ignore-call */ bind($value);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
81
    }
82
83 98
    protected function normalizeOperator($where)
84
    {
85 98
        if (isset($where['operator'])) {
86 98
            $where['operator'] = $this->translateOperator($where['operator']);
87
        }
88 98
        if (! isset($where['operator'])) {
89
            $where['operator'] = $this->getOperatorByWhereType($where['type']);
90
        }
91
92 98
            return $where;
93
    }
94
95
    /**
96
     * Translate sql operators to their AQL equivalent where possible.
97
     *
98
     * @param string $operator
99
     *
100
     * @return mixed|string
101
     */
102 98
    private function translateOperator(string $operator)
103
    {
104 98
        if (isset($this->operatorTranslations[strtolower($operator)])) {
105 89
            $operator = $this->operatorTranslations[$operator];
106
        }
107
108 98
        return $operator;
109
    }
110
111
112
    /**
113
     * Compile a basic where clause.
114
     *
115
     * @param  IluminateBuilder  $query
116
     * @param  array  $where
117
     * @return array
118
     */
119 83
    protected function whereBasic(IluminateBuilder $query, $where)
120
    {
121 83
        $predicate = [];
122
123 83
        $where = $this->normalizeOperator($where);
124
125 83
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
0 ignored issues
show
Bug introduced by
It seems like normalizeColumn() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

125
        /** @scrutinizer ignore-call */ 
126
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
Loading history...
126 83
        $predicate[1] = $where['operator'];
127 83
        $predicate[2] = $this->parameter($query, $where['value']);
128 83
        $predicate[3] = $where['boolean'];
129
130 83
        return $predicate;
131
    }
132
133
    /**
134
     * Compile a "between" where clause.
135
     *
136
     * @param  IluminateBuilder  $query
137
     * @param  array  $where
138
     * @return string
139
     */
140 3
    protected function whereBetween(IluminateBuilder $query, $where)
141
    {
142 3
        $predicate = [];
143
144 3
        [$minOperator, $maxOperator, $boolean] = $this->getBetweenOperators($where['not']);
145
146 3
        $min = $this->parameter($query, reset($where['values']));
147
148 3
        $max = $this->parameter($query, end($where['values']));
149
150 3
        $predicate[0][0] = $this->normalizeColumn($query, $where['column']);
151 3
        $predicate[0][1] = $minOperator;
152 3
        $predicate[0][2] = $min;
153 3
        $predicate[0][3] = $where['boolean'];
154
155 3
        $predicate[1][0] = $this->normalizeColumn($query, $where['column']);
156 3
        $predicate[1][1] = $maxOperator;
157 3
        $predicate[1][2] = $max;
158 3
        $predicate[1][3] = $boolean;
159
160 3
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
161
    }
162
163
    /**
164
     * Generate operators for between and 'not between'
165
     * @param  bool  $notBetween
166
     * @return string[]
167
     */
168 4
    protected function getBetweenOperators(bool $notBetween)
169
    {
170 4
        $minOperator = '>=';
171 4
        $maxOperator = '<=';
172 4
        $boolean = 'AND';
173
174 4
        if ($notBetween) {
175 1
            $minOperator = '<';
176 1
            $maxOperator = '>';
177 1
            $boolean = 'OR';
178
        }
179
180 4
        return [$minOperator, $maxOperator, $boolean];
181
    }
182
183
    /**
184
     * Compile a "between" where clause.
185
     *
186
     * @param  IluminateBuilder  $query
187
     * @param  array  $where
188
     * @return string
189
     */
190 1
    protected function whereBetweenColumns(IluminateBuilder $query, $where)
191
    {
192 1
        $predicate = [];
193
194 1
        [$minOperator, $maxOperator, $boolean] = $this->getBetweenOperators($where['not']);
195
196 1
        $column = $this->normalizeColumn($query, $where['column']);
197
198 1
        $predicate[0][0] = $column;
199 1
        $predicate[0][1] = $minOperator;
200 1
        $predicate[0][2] = $this->normalizeColumn($query, reset($where['values']));
201 1
        $predicate[0][3] = $where['boolean'];
202
203 1
        $predicate[1][0] = $column;
204 1
        $predicate[1][1] = $maxOperator;
205 1
        $predicate[1][2] = $this->normalizeColumn($query, end($where['values']));
206 1
        $predicate[1][3] = $boolean;
207
208 1
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
209
    }
210
211
212
    /**
213
     * Compile a where clause comparing two columns..
214
     *
215
     * @param  IluminateBuilder  $query
216
     * @param  array  $where
217
     * @return string
218
     */
219 27
    protected function whereColumn(IluminateBuilder $query, $where)
220
    {
221 27
        $predicate = [];
222
223 27
        $where = $this->normalizeOperator($where);
224
225 27
        $predicate[0] = $this->normalizeColumn($query, $where['first']);
226 27
        $predicate[1] = $where['operator'];
227 27
        $predicate[2] = $this->normalizeColumn($query, $where['second']);
228 27
        $predicate[3] = $where['boolean'];
229
230 27
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
231
    }
232
233
    /**
234
     * Compile a "where null" clause.
235
     *
236
     * @param  IluminateBuilder  $query
237
     * @param  array  $where
238
     * @return string
239
     */
240 18
    protected function whereNull(IluminateBuilder $query, $where)
241
    {
242 18
        $predicate = [];
243
244 18
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
245 18
        $predicate[1] = '==';
246 18
        $predicate[2] = null;
247 18
        $predicate[3] = $where['boolean'];
248
249 18
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
250
    }
251
252
    /**
253
     * Compile a "where not null" clause.
254
     *
255
     * @param  IluminateBuilder  $query
256
     * @param  array  $where
257
     * @return string
258
     */
259 16
    protected function whereNotNull(IluminateBuilder $query, $where)
260
    {
261 16
        $predicate = [];
262
263 16
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
264 16
        $predicate[1] = '!=';
265 16
        $predicate[2] = null;
266 16
        $predicate[3] = $where['boolean'];
267
268 16
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
269
    }
270
271
    /**
272
     * Compile a "where in" clause.
273
     *
274
     * @param  IluminateBuilder  $query
275
     * @param  array  $where
276
     * @return string
277
     */
278 12
    protected function whereIn(IluminateBuilder $query, $where)
279
    {
280 12
        $predicate = [];
281
282 12
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
283 12
        $predicate[1] = 'IN';
284 12
        $predicate[2] = $this->parameter($query, $where['values']);
285 12
        $predicate[3] = $where['boolean'];
286
287 12
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
288
    }
289
290
    /**
291
     * Compile a "where in raw" clause.
292
     *
293
     * For safety, whereIntegerInRaw ensures this method is only used with integer values.
294
     *
295
     * @param  IluminateBuilder  $query
296
     * @param  array  $where
297
     * @return string
298
     */
299 1
    protected function whereInRaw(IluminateBuilder $query, $where)
300
    {
301 1
        $predicate = [];
302
303 1
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
304 1
        $predicate[1] = 'IN';
305 1
        $predicate[2] = '[' . implode(', ', $where['values']) . ']';
306 1
        $predicate[3] = $where['boolean'];
307
308 1
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
309
    }
310
311
    /**
312
     * Compile a "where not in" clause.
313
     *
314
     * @param  IluminateBuilder  $query
315
     * @param  array  $where
316
     * @return string
317
     */
318 1
    protected function whereNotIn(IluminateBuilder $query, $where)
319
    {
320 1
        $predicate = [];
321
322 1
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
323 1
        $predicate[1] = 'NOT IN';
324 1
        $predicate[2] = $this->parameter($query, $where['values']);
325 1
        $predicate[3] = $where['boolean'];
326
327 1
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
328
    }
329
330
    /**
331
     * Compile a "where not in raw" clause.
332
     *
333
     * For safety, whereIntegerInRaw ensures this method is only used with integer values.
334
     *
335
     * @param  IluminateBuilder  $query
336
     * @param  array  $where
337
     * @return string
338
     */
339 1
    protected function whereNotInRaw(IluminateBuilder $query, $where)
340
    {
341 1
        $predicate = [];
342
343 1
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
344 1
        $predicate[1] = 'NOT IN';
345 1
        $predicate[2] = '[' . implode(', ', $where['values']) . ']';
346 1
        $predicate[3] = $where['boolean'];
347 1
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
348
    }
349
350
    /**
351
     * Compile a "whereJsonContains" clause.
352
     *
353
     * @param Builder $query
354
     * @param array $where
355
     * @return string
356
     * @throws BindException
357
     */
358 1
    protected function whereJsonContains(Builder $query, $where)
359
    {
360 1
        $predicate = [];
361
362 1
        $operator = $where['not'] ? 'NOT IN' : 'IN';
363
364 1
        $predicate[0] = $query->aqb->bind($where['value']);
365 1
        $predicate[1] = $operator;
366 1
        $predicate[2] = $this->normalizeColumn($query, $where['column']);
367 1
        $predicate[3] = $where['boolean'];
368
369 1
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
370
    }
371
372
    /**
373
     * Compile a "whereJsonContains" clause.
374
     *
375
     * @param  Builder  $query
376
     * @param  array  $where
377
     * @return array
378
     */
379 1
    protected function whereJsonLength(Builder $query, $where)
380
    {
381 1
        $predicate = [];
382
383 1
        $where = $this->normalizeOperator($where);
384
385 1
        $column = $this->normalizeColumn($query, $where['column']);
386
387 1
        $predicate[0] = $query->aqb->length($column);
0 ignored issues
show
Bug introduced by
The method length() does not exist on LaravelFreelancerNL\Flue...ions\FunctionExpression. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

387
        /** @scrutinizer ignore-call */ 
388
        $predicate[0] = $query->aqb->length($column);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
388 1
        $predicate[1] = $where['operator'];
389 1
        $predicate[2] = $this->parameter($query, $where['value']);
390 1
        $predicate[3] = $where['boolean'];
391
392 1
        return $predicate;
393
    }
394
395
396
    /**
397
     * Compile a where date clause.
398
     *
399
     * @param  Builder  $query
400
     * @param  array  $where
401
     * @return array
402
     */
403 1
    protected function whereDate(Builder $query, $where)
404
    {
405 1
        $predicate = [];
406
407 1
        $where = $this->normalizeOperator($where);
408
409 1
        $predicate[0] = $query->aqb->dateFormat($this->normalizeColumn($query, $where['column']), "%yyyy-%mm-%dd");
0 ignored issues
show
Bug introduced by
The method dateFormat() does not exist on LaravelFreelancerNL\Flue...ions\FunctionExpression. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

409
        /** @scrutinizer ignore-call */ 
410
        $predicate[0] = $query->aqb->dateFormat($this->normalizeColumn($query, $where['column']), "%yyyy-%mm-%dd");

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
410 1
        $predicate[1] = $where['operator'];
411 1
        $predicate[2] = $this->parameter($query, $where['value']);
412 1
        $predicate[3] = $where['boolean'];
413
414 1
        return $predicate;
415
    }
416
417
    /**
418
     * Compile a where year clause.
419
     *
420
     * @param  Builder  $query
421
     * @param  array  $where
422
     * @return array
423
     */
424 1
    protected function whereYear(Builder $query, $where)
425
    {
426 1
        $predicate = [];
427
428 1
        $where = $this->normalizeOperator($where);
429
430 1
        $predicate[0] = $query->aqb->dateYear($this->normalizeColumn($query, $where['column']));
0 ignored issues
show
Bug introduced by
The method dateYear() does not exist on LaravelFreelancerNL\Flue...ions\FunctionExpression. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

430
        /** @scrutinizer ignore-call */ 
431
        $predicate[0] = $query->aqb->dateYear($this->normalizeColumn($query, $where['column']));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
431 1
        $predicate[1] = $where['operator'];
432 1
        $predicate[2] = $this->parameter($query, $where['value']);
433 1
        $predicate[3] = $where['boolean'];
434
435 1
        return $predicate;
436
    }
437
438
    /**
439
     * Compile a where month clause.
440
     *
441
     * @param  Builder  $query
442
     * @param  array  $where
443
     * @return array
444
     */
445 1
    protected function whereMonth(Builder $query, $where)
446
    {
447 1
        $predicate = [];
448
449 1
        $where = $this->normalizeOperator($where);
450
451 1
        $predicate[0] = $query->aqb->dateMonth($this->normalizeColumn($query, $where['column']));
0 ignored issues
show
Bug introduced by
The method dateMonth() does not exist on LaravelFreelancerNL\Flue...ions\FunctionExpression. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

451
        /** @scrutinizer ignore-call */ 
452
        $predicate[0] = $query->aqb->dateMonth($this->normalizeColumn($query, $where['column']));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
452 1
        $predicate[1] = $where['operator'];
453 1
        $predicate[2] = $this->parameter($query, $where['value']);
454 1
        $predicate[3] = $where['boolean'];
455
456 1
        return $predicate;
457
    }
458
459
460
    /**
461
     * Compile a where day clause.
462
     *
463
     * @param  Builder  $query
464
     * @param  array  $where
465
     * @return array
466
     */
467 1
    protected function whereDay(Builder $query, $where)
468
    {
469 1
        $predicate = [];
470
471 1
        $where = $this->normalizeOperator($where);
472
473 1
        $predicate[0] = $query->aqb->dateDay($this->normalizeColumn($query, $where['column']));
0 ignored issues
show
Bug introduced by
The method dateDay() does not exist on LaravelFreelancerNL\Flue...ions\FunctionExpression. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

473
        /** @scrutinizer ignore-call */ 
474
        $predicate[0] = $query->aqb->dateDay($this->normalizeColumn($query, $where['column']));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
474 1
        $predicate[1] = $where['operator'];
475 1
        $predicate[2] = $this->parameter($query, $where['value']);
476 1
        $predicate[3] = $where['boolean'];
477
478 1
        return $predicate;
479
    }
480
481
    /**
482
     * Compile a where time clause.
483
     *
484
     * @param  Builder  $query
485
     * @param  array  $where
486
     * @return array
487
     */
488 1
    protected function whereTime(Builder $query, $where)
489
    {
490 1
        $predicate = [];
491
492 1
        $where = $this->normalizeOperator($where);
493
494 1
        $predicate[0] = $query->aqb->dateFormat($this->normalizeColumn($query, $where['column']), "%hh:%ii:%ss");
495 1
        $predicate[1] = $where['operator'];
496 1
        $predicate[2] = $this->parameter($query, $where['value']);
497 1
        $predicate[3] = $where['boolean'];
498
499 1
        return $predicate;
500
    }
501
502
    /**
503
     * Compile a nested where clause.
504
     *
505
     * @param  Builder  $query
506
     * @param  array  $where
507
     * @return string
508
     */
509 21
    protected function whereNested(Builder $query, $where)
510
    {
511 21
        $predicates = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $predicates is dead and can be removed.
Loading history...
512 21
        $predicates = $this->compileWheresToArray($where['query']);
513
514 21
        $query->aqb->binds = array_merge($query->aqb->binds, $where['query']->aqb->binds);
0 ignored issues
show
Bug introduced by
The property binds does not seem to exist on LaravelFreelancerNL\Flue...ions\FunctionExpression.
Loading history...
515 21
        $query->aqb->collections = array_merge_recursive($query->aqb->collections, $where['query']->aqb->collections);
0 ignored issues
show
Bug introduced by
The property collections does not seem to exist on LaravelFreelancerNL\Flue...ions\FunctionExpression.
Loading history...
516
517 21
        return $predicates;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicates returns the type array which is incompatible with the documented return type string.
Loading history...
518
    }
519
520
    /**
521
     * Compile a where condition with a sub-select.
522
     *
523
     * @param  Builder  $query
524
     * @param  array  $where
525
     * @return string
526
     */
527 1
    protected function whereSub(Builder $query, $where)
528
    {
529 1
        $predicate = [];
530
531 1
        $where = $this->normalizeOperator($where);
532
533 1
        $predicate[0] = $this->normalizeColumn($query, $where['column']);
534 1
        $predicate[1] = $where['operator'];
535 1
        $predicate[2] = $where['query']->aqb;
536 1
        $predicate[3] = $where['boolean'];
537
538 1
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
539
    }
540
541
    /**
542
     * Compile a where exists clause.
543
     *
544
     *  @SuppressWarnings(PHPMD.UnusedFormalParameter)
545
     *
546
     * @param  Builder  $query
547
     * @param  array  $where
548
     * @return string
549
     */
550 7
    protected function whereExists(Builder $query, $where)
551
    {
552 7
        $predicate = [];
553
554 7
        $predicate[0] = $where['query']->aqb;
555 7
        $predicate[1] = $where['operator'];
556 7
        $predicate[2] = $where['value'];
557 7
        $predicate[3] = $where['boolean'];
558
559 7
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
560
    }
561
562
    /**
563
     * Compile a where exists clause.
564
     *
565
     *  @SuppressWarnings(PHPMD.UnusedFormalParameter)
566
     *
567
     * @param  Builder  $query
568
     * @param  array  $where
569
     * @return string
570
     */
571
    protected function whereNotExists(Builder $query, $where)
572
    {
573
        $predicate = [];
574
575
        $predicate[0] = $where['query']->aqb;
576
        $predicate[1] = $where['operator'];
577
        $predicate[2] = $where['value'];
578
        $predicate[3] = $where['boolean'];
579
580
        return $predicate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $predicate returns the type array which is incompatible with the documented return type string.
Loading history...
581
    }
582
}
583