Complex classes like BuildsQueries often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use BuildsQueries, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
9 | trait BuildsQueries |
||
10 | { |
||
11 | /** |
||
12 | * Set the columns to be selected. |
||
13 | * |
||
14 | * @param array|mixed $columns |
||
15 | * @return $this |
||
16 | */ |
||
17 | 1 | public function select($columns = ['*']) |
|
23 | |||
24 | /** |
||
25 | * Add a new "raw" select expression to the query. |
||
26 | * |
||
27 | * @param string $expression |
||
28 | * @param array $bindings |
||
29 | * @return $this |
||
30 | */ |
||
31 | 1 | public function selectRaw($expression, array $bindings = []) |
|
37 | |||
38 | /** |
||
39 | * Makes "from" fetch from a subquery. |
||
40 | * |
||
41 | * @param \Closure|\Illuminate\Database\Query\Builder|string $query |
||
42 | * @param string $as |
||
43 | * @return \Illuminate\Database\Query\Builder|static |
||
44 | * |
||
45 | * @throws \InvalidArgumentException |
||
46 | */ |
||
47 | public function fromSub($query, $as) |
||
53 | |||
54 | /** |
||
55 | * Add a subselect expression to the query. |
||
56 | * |
||
57 | * @param \Closure|\Illuminate\Database\Query\Builder|string $query |
||
58 | * @param string $as |
||
59 | * @return $this |
||
60 | * |
||
61 | * @throws \InvalidArgumentException |
||
62 | */ |
||
63 | 1 | public function selectSub($query, $as) |
|
69 | |||
70 | /** |
||
71 | * Add a new select column to the query. |
||
72 | * |
||
73 | * @param array|mixed $column |
||
74 | * @return $this |
||
75 | */ |
||
76 | 1 | public function addSelect($column) |
|
82 | |||
83 | /** |
||
84 | * Force the query to only return distinct results. |
||
85 | * |
||
86 | * @return $this |
||
87 | */ |
||
88 | 1 | public function distinct() |
|
94 | |||
95 | /** |
||
96 | * Set the table which the query is targeting. |
||
97 | * |
||
98 | * @param string $table |
||
99 | * @return $this |
||
100 | */ |
||
101 | 1 | public function from($table) |
|
107 | |||
108 | /** |
||
109 | * Add a join clause to the query. |
||
110 | * |
||
111 | * @param string $table |
||
112 | * @param string $first |
||
113 | * @param string $operator |
||
114 | * @param string $second |
||
115 | * @param string $type |
||
116 | * @param bool $where |
||
117 | * @return $this |
||
118 | */ |
||
119 | 1 | public function join($table, $first, $operator = null, $second = null, $type = 'inner', $where = false) |
|
125 | |||
126 | /** |
||
127 | * Add a "join where" clause to the query. |
||
128 | * |
||
129 | * @param string $table |
||
130 | * @param string $first |
||
131 | * @param string $operator |
||
132 | * @param string $second |
||
133 | * @param string $type |
||
134 | * @return $this |
||
135 | */ |
||
136 | 1 | public function joinWhere($table, $first, $operator, $second, $type = 'inner') |
|
142 | |||
143 | /** |
||
144 | * Add a subquery join clause to the query. |
||
145 | * |
||
146 | * @param \Closure|\Illuminate\Database\Query\Builder|string $query |
||
147 | * @param string $as |
||
148 | * @param string $first |
||
149 | * @param string|null $operator |
||
150 | * @param string|null $second |
||
151 | * @param string $type |
||
152 | * @param bool $where |
||
153 | * @return \Illuminate\Database\Query\Builder|static |
||
154 | * |
||
155 | * @throws \InvalidArgumentException |
||
156 | */ |
||
157 | public function joinSub($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false) |
||
163 | |||
164 | /** |
||
165 | * Add a left join to the query. |
||
166 | * |
||
167 | * @param string $table |
||
168 | * @param string $first |
||
169 | * @param string $operator |
||
170 | * @param string $second |
||
171 | * @return $this |
||
172 | */ |
||
173 | 1 | public function leftJoin($table, $first, $operator = null, $second = null) |
|
179 | |||
180 | /** |
||
181 | * Add a "join where" clause to the query. |
||
182 | * |
||
183 | * @param string $table |
||
184 | * @param string $first |
||
185 | * @param string $operator |
||
186 | * @param string $second |
||
187 | * @return $this |
||
188 | */ |
||
189 | 1 | public function leftJoinWhere($table, $first, $operator, $second) |
|
195 | |||
196 | /** |
||
197 | * Add a subquery left join to the query. |
||
198 | * |
||
199 | * @param \Closure|\Illuminate\Database\Query\Builder|string $query |
||
200 | * @param string $as |
||
201 | * @param string $first |
||
202 | * @param string|null $operator |
||
203 | * @param string|null $second |
||
204 | * @return \Illuminate\Database\Query\Builder|static |
||
205 | */ |
||
206 | public function leftJoinSub($query, $as, $first, $operator = null, $second = null) |
||
212 | |||
213 | /** |
||
214 | * Add a right join to the query. |
||
215 | * |
||
216 | * @param string $table |
||
217 | * @param string $first |
||
218 | * @param string $operator |
||
219 | * @param string $second |
||
220 | * @return $this |
||
221 | */ |
||
222 | 1 | public function rightJoin($table, $first, $operator = null, $second = null) |
|
228 | |||
229 | /** |
||
230 | * Add a "right join where" clause to the query. |
||
231 | * |
||
232 | * @param string $table |
||
233 | * @param string $first |
||
234 | * @param string $operator |
||
235 | * @param string $second |
||
236 | * @return $this |
||
237 | */ |
||
238 | 1 | public function rightJoinWhere($table, $first, $operator, $second) |
|
244 | |||
245 | /** |
||
246 | * Add a subquery right join to the query. |
||
247 | * |
||
248 | * @param \Closure|\Illuminate\Database\Query\Builder|string $query |
||
249 | * @param string $as |
||
250 | * @param string $first |
||
251 | * @param string|null $operator |
||
252 | * @param string|null $second |
||
253 | * @return \Illuminate\Database\Query\Builder|static |
||
254 | */ |
||
255 | public function rightJoinSub($query, $as, $first, $operator = null, $second = null) |
||
261 | |||
262 | /** |
||
263 | * Add a "cross join" clause to the query. |
||
264 | * |
||
265 | * @param string $table |
||
266 | * @param string $first |
||
267 | * @param string $operator |
||
268 | * @param string $second |
||
269 | * @return $this |
||
270 | */ |
||
271 | 1 | public function crossJoin($table, $first = null, $operator = null, $second = null) |
|
277 | |||
278 | /** |
||
279 | * Merge an array of where clauses and bindings. |
||
280 | * |
||
281 | * @param array $wheres |
||
282 | * @param array $bindings |
||
283 | * @return void |
||
284 | */ |
||
285 | public function mergeWheres($wheres, $bindings) |
||
291 | |||
292 | /** |
||
293 | * Pass the query to a given callback. |
||
294 | * |
||
295 | * @param \Closure $callback |
||
296 | * @return $this |
||
297 | */ |
||
298 | 1 | public function tap($callback) |
|
304 | |||
305 | /** |
||
306 | * Add a basic where clause to the query. |
||
307 | * |
||
308 | * @param string|array|\Closure $column |
||
309 | * @param string $operator |
||
310 | * @param mixed $value |
||
311 | * @param string $boolean |
||
312 | * @return $this |
||
313 | */ |
||
314 | 12 | public function where($column, $operator = null, $value = null, $boolean = 'and') |
|
320 | |||
321 | /** |
||
322 | * Add an "or where" clause to the query. |
||
323 | * |
||
324 | * @param \Closure|string $column |
||
325 | * @param string $operator |
||
326 | * @param mixed $value |
||
327 | * @return $this |
||
328 | */ |
||
329 | 1 | public function orWhere($column, $operator = null, $value = null) |
|
335 | |||
336 | /** |
||
337 | * Add a "where" clause comparing two columns to the query. |
||
338 | * |
||
339 | * @param string|array $first |
||
340 | * @param string|null $operator |
||
341 | * @param string|null $second |
||
342 | * @param string|null $boolean |
||
343 | * @return $this |
||
344 | */ |
||
345 | 1 | public function whereColumn($first, $operator = null, $second = null, $boolean = 'and') |
|
351 | |||
352 | /** |
||
353 | * Add an "or where" clause comparing two columns to the query. |
||
354 | * |
||
355 | * @param string|array $first |
||
356 | * @param string|null $operator |
||
357 | * @param string|null $second |
||
358 | * @return $this |
||
359 | */ |
||
360 | 1 | public function orWhereColumn($first, $operator = null, $second = null) |
|
366 | |||
367 | /** |
||
368 | * Add a raw where clause to the query. |
||
369 | * |
||
370 | * @param string $sql |
||
371 | * @param mixed $bindings |
||
372 | * @param string $boolean |
||
373 | * @return $this |
||
374 | */ |
||
375 | 1 | public function whereRaw($sql, $bindings = [], $boolean = 'and') |
|
381 | |||
382 | /** |
||
383 | * Add a raw or where clause to the query. |
||
384 | * |
||
385 | * @param string $sql |
||
386 | * @param array $bindings |
||
387 | * @return $this |
||
388 | */ |
||
389 | 1 | public function orWhereRaw($sql, array $bindings = []) |
|
395 | |||
396 | /** |
||
397 | * Add a "where in" clause to the query. |
||
398 | * |
||
399 | * @param string $column |
||
400 | * @param mixed $values |
||
401 | * @param string $boolean |
||
402 | * @param bool $not |
||
403 | * @return $this |
||
404 | */ |
||
405 | 3 | public function whereIn($column, $values, $boolean = 'and', $not = false) |
|
411 | |||
412 | /** |
||
413 | * Add an "or where in" clause to the query. |
||
414 | * |
||
415 | * @param string $column |
||
416 | * @param mixed $values |
||
417 | * @return $this |
||
418 | */ |
||
419 | 2 | public function orWhereIn($column, $values) |
|
425 | |||
426 | /** |
||
427 | * Add a "where not in" clause to the query. |
||
428 | * |
||
429 | * @param string $column |
||
430 | * @param mixed $values |
||
431 | * @param string $boolean |
||
432 | * @return $this |
||
433 | */ |
||
434 | 1 | public function whereNotIn($column, $values, $boolean = 'and') |
|
440 | |||
441 | /** |
||
442 | * Add an "or where not in" clause to the query. |
||
443 | * |
||
444 | * @param string $column |
||
445 | * @param mixed $values |
||
446 | * @return $this |
||
447 | */ |
||
448 | 1 | public function orWhereNotIn($column, $values) |
|
454 | |||
455 | /** |
||
456 | * Add a "where null" clause to the query. |
||
457 | * |
||
458 | * @param string $column |
||
459 | * @param string $boolean |
||
460 | * @param bool $not |
||
461 | * @return $this |
||
462 | */ |
||
463 | 1 | public function whereNull($column, $boolean = 'and', $not = false) |
|
469 | |||
470 | /** |
||
471 | * Add an "or where null" clause to the query. |
||
472 | * |
||
473 | * @param string $column |
||
474 | * @return $this |
||
475 | */ |
||
476 | 1 | public function orWhereNull($column) |
|
482 | |||
483 | /** |
||
484 | * Add a "where not null" clause to the query. |
||
485 | * |
||
486 | * @param string $column |
||
487 | * @param string $boolean |
||
488 | * @return $this |
||
489 | */ |
||
490 | 1 | public function whereNotNull($column, $boolean = 'and') |
|
496 | |||
497 | /** |
||
498 | * Add a where between statement to the query. |
||
499 | * |
||
500 | * @param string $column |
||
501 | * @param array $values |
||
502 | * @param string $boolean |
||
503 | * @param bool $not |
||
504 | * @return $this |
||
505 | */ |
||
506 | 3 | public function whereBetween($column, array $values, $boolean = 'and', $not = false) |
|
512 | |||
513 | /** |
||
514 | * Add an or where between statement to the query. |
||
515 | * |
||
516 | * @param string $column |
||
517 | * @param array $values |
||
518 | * @return $this |
||
519 | */ |
||
520 | 1 | public function orWhereBetween($column, array $values) |
|
526 | |||
527 | /** |
||
528 | * Add a where not between statement to the query. |
||
529 | * |
||
530 | * @param string $column |
||
531 | * @param array $values |
||
532 | * @param string $boolean |
||
533 | * @return $this |
||
534 | */ |
||
535 | 1 | public function whereNotBetween($column, array $values, $boolean = 'and') |
|
541 | |||
542 | /** |
||
543 | * Add an or where not between statement to the query. |
||
544 | * |
||
545 | * @param string $column |
||
546 | * @param array $values |
||
547 | * @return $this |
||
548 | */ |
||
549 | 1 | public function orWhereNotBetween($column, array $values) |
|
555 | |||
556 | /** |
||
557 | * Add an "or where not null" clause to the query. |
||
558 | * |
||
559 | * @param string $column |
||
560 | * @return $this |
||
561 | */ |
||
562 | 1 | public function orWhereNotNull($column) |
|
568 | |||
569 | /** |
||
570 | * Add a "where date" statement to the query. |
||
571 | * |
||
572 | * @param string $column |
||
573 | * @param string $operator |
||
574 | * @param mixed $value |
||
575 | * @param string $boolean |
||
576 | * @return $this |
||
577 | */ |
||
578 | 1 | public function whereDate($column, $operator, $value = null, $boolean = 'and') |
|
584 | |||
585 | /** |
||
586 | * Add an "or where date" statement to the query. |
||
587 | * |
||
588 | * @param string $column |
||
589 | * @param string $operator |
||
590 | * @param string $value |
||
591 | * @return $this |
||
592 | */ |
||
593 | 1 | public function orWhereDate($column, $operator, $value) |
|
599 | |||
600 | /** |
||
601 | * Add a "where time" statement to the query. |
||
602 | * |
||
603 | * @param string $column |
||
604 | * @param string $operator |
||
605 | * @param int $value |
||
606 | * @param string $boolean |
||
607 | * @return $this |
||
608 | */ |
||
609 | 1 | public function whereTime($column, $operator, $value, $boolean = 'and') |
|
615 | |||
616 | /** |
||
617 | * Add an "or where time" statement to the query. |
||
618 | * |
||
619 | * @param string $column |
||
620 | * @param string $operator |
||
621 | * @param int $value |
||
622 | * @return $this |
||
623 | */ |
||
624 | 1 | public function orWhereTime($column, $operator, $value) |
|
630 | |||
631 | /** |
||
632 | * Add a "where day" statement to the query. |
||
633 | * |
||
634 | * @param string $column |
||
635 | * @param string $operator |
||
636 | * @param mixed $value |
||
637 | * @param string $boolean |
||
638 | * @return $this |
||
639 | */ |
||
640 | 1 | public function whereDay($column, $operator, $value = null, $boolean = 'and') |
|
646 | |||
647 | /** |
||
648 | * Add a "where month" statement to the query. |
||
649 | * |
||
650 | * @param string $column |
||
651 | * @param string $operator |
||
652 | * @param mixed $value |
||
653 | * @param string $boolean |
||
654 | * @return $this |
||
655 | */ |
||
656 | 1 | public function whereMonth($column, $operator, $value = null, $boolean = 'and') |
|
662 | |||
663 | /** |
||
664 | * Add a "where year" statement to the query. |
||
665 | * |
||
666 | * @param string $column |
||
667 | * @param string $operator |
||
668 | * @param mixed $value |
||
669 | * @param string $boolean |
||
670 | * @return $this |
||
671 | */ |
||
672 | 1 | public function whereYear($column, $operator, $value = null, $boolean = 'and') |
|
678 | |||
679 | /** |
||
680 | * Add a nested where statement to the query. |
||
681 | * |
||
682 | * @param \Closure $callback |
||
683 | * @param string $boolean |
||
684 | * @return $this |
||
685 | */ |
||
686 | 1 | public function whereNested(Closure $callback, $boolean = 'and') |
|
692 | |||
693 | /** |
||
694 | * Add another query builder as a nested where to the query builder. |
||
695 | * |
||
696 | * @param $this $query |
||
697 | * @param string $boolean |
||
698 | * @return $this |
||
699 | */ |
||
700 | 1 | public function addNestedWhereQuery($query, $boolean = 'and') |
|
706 | |||
707 | /** |
||
708 | * Add an exists clause to the query. |
||
709 | * |
||
710 | * @param \Closure $callback |
||
711 | * @param string $boolean |
||
712 | * @param bool $not |
||
713 | * @return $this |
||
714 | */ |
||
715 | 1 | public function whereExists(Closure $callback, $boolean = 'and', $not = false) |
|
721 | |||
722 | /** |
||
723 | * Add an or exists clause to the query. |
||
724 | * |
||
725 | * @param \Closure $callback |
||
726 | * @param bool $not |
||
727 | * @return $this |
||
728 | */ |
||
729 | 1 | public function orWhereExists(Closure $callback, $not = false) |
|
735 | |||
736 | /** |
||
737 | * Add a where not exists clause to the query. |
||
738 | * |
||
739 | * @param \Closure $callback |
||
740 | * @param string $boolean |
||
741 | * @return $this |
||
742 | */ |
||
743 | 1 | public function whereNotExists(Closure $callback, $boolean = 'and') |
|
749 | |||
750 | /** |
||
751 | * Add a where not exists clause to the query. |
||
752 | * |
||
753 | * @param \Closure $callback |
||
754 | * @return $this |
||
755 | */ |
||
756 | 1 | public function orWhereNotExists(Closure $callback) |
|
762 | |||
763 | /** |
||
764 | * Add an exists clause to the query. |
||
765 | * |
||
766 | * @param \Illuminate\Database\Query\Builder $query |
||
767 | * @param string $boolean |
||
768 | * @param bool $not |
||
769 | * @return $this |
||
770 | */ |
||
771 | 1 | public function addWhereExistsQuery(Builder $query, $boolean = 'and', $not = false) |
|
777 | |||
778 | /** |
||
779 | * Handles dynamic "where" clauses to the query. |
||
780 | * |
||
781 | * @param string $method |
||
782 | * @param string $parameters |
||
783 | * @return $this |
||
784 | */ |
||
785 | 2 | public function dynamicWhere($method, $parameters) |
|
791 | |||
792 | /** |
||
793 | * Add a "group by" clause to the query. |
||
794 | * |
||
795 | * @param array ...$groups |
||
796 | * @return $this |
||
797 | */ |
||
798 | 1 | public function groupBy() |
|
804 | |||
805 | /** |
||
806 | * Add a "having" clause to the query. |
||
807 | * |
||
808 | * @param string $column |
||
809 | * @param string $operator |
||
810 | * @param string $value |
||
811 | * @param string $boolean |
||
812 | * @return $this |
||
813 | */ |
||
814 | 1 | public function having($column, $operator = null, $value = null, $boolean = 'and') |
|
820 | |||
821 | /** |
||
822 | * Add a "or having" clause to the query. |
||
823 | * |
||
824 | * @param string $column |
||
825 | * @param string $operator |
||
826 | * @param string $value |
||
827 | * @return $this |
||
828 | */ |
||
829 | 1 | public function orHaving($column, $operator = null, $value = null) |
|
835 | |||
836 | /** |
||
837 | * Add a raw having clause to the query. |
||
838 | * |
||
839 | * @param string $sql |
||
840 | * @param array $bindings |
||
841 | * @param string $boolean |
||
842 | * @return $this |
||
843 | */ |
||
844 | 1 | public function havingRaw($sql, array $bindings = [], $boolean = 'and') |
|
850 | |||
851 | /** |
||
852 | * Add a raw or having clause to the query. |
||
853 | * |
||
854 | * @param string $sql |
||
855 | * @param array $bindings |
||
856 | * @return $this |
||
857 | */ |
||
858 | 1 | public function orHavingRaw($sql, array $bindings = []) |
|
864 | |||
865 | /** |
||
866 | * Add an "order by" clause to the query. |
||
867 | * |
||
868 | * @param string $column |
||
869 | * @param string $direction |
||
870 | * @return $this |
||
871 | */ |
||
872 | 4 | public function orderBy($column, $direction = 'asc') |
|
878 | |||
879 | /** |
||
880 | * Add a descending "order by" clause to the query. |
||
881 | * |
||
882 | * @param string $column |
||
883 | * @return $this |
||
884 | */ |
||
885 | 1 | public function orderByDesc($column) |
|
891 | |||
892 | /** |
||
893 | * Add an "order by" clause for a timestamp to the query. |
||
894 | * |
||
895 | * @param string $column |
||
896 | * @return $this |
||
897 | */ |
||
898 | 1 | public function latest($column = 'created_at') |
|
904 | |||
905 | /** |
||
906 | * Add an "order by" clause for a timestamp to the query. |
||
907 | * |
||
908 | * @param string $column |
||
909 | * @return $this |
||
910 | */ |
||
911 | 1 | public function oldest($column = 'created_at') |
|
917 | |||
918 | /** |
||
919 | * Put the query's results in random order. |
||
920 | * |
||
921 | * @param string $seed |
||
922 | * @return $this |
||
923 | */ |
||
924 | 1 | public function inRandomOrder($seed = '') |
|
930 | |||
931 | /** |
||
932 | * Add a raw "order by" clause to the query. |
||
933 | * |
||
934 | * @param string $sql |
||
935 | * @param array $bindings |
||
936 | * @return $this |
||
937 | */ |
||
938 | 1 | public function orderByRaw($sql, $bindings = []) |
|
944 | |||
945 | /** |
||
946 | * Alias to set the "offset" value of the query. |
||
947 | * |
||
948 | * @param int $value |
||
949 | * @return $this |
||
950 | */ |
||
951 | 1 | public function skip($value) |
|
957 | |||
958 | /** |
||
959 | * Set the "offset" value of the query. |
||
960 | * |
||
961 | * @param int $value |
||
962 | * @return $this |
||
963 | */ |
||
964 | 1 | public function offset($value) |
|
970 | |||
971 | /** |
||
972 | * Alias to set the "limit" value of the query. |
||
973 | * |
||
974 | * @param int $value |
||
975 | * @return $this |
||
976 | */ |
||
977 | 1 | public function take($value) |
|
983 | |||
984 | /** |
||
985 | * Set the "limit" value of the query. |
||
986 | * |
||
987 | * @param int $value |
||
988 | * @return $this |
||
989 | */ |
||
990 | 1 | public function limit($value) |
|
996 | |||
997 | /** |
||
998 | * Set the limit and offset for a given page. |
||
999 | * |
||
1000 | * @param int $page |
||
1001 | * @param int $perPage |
||
1002 | * @return $this |
||
1003 | */ |
||
1004 | 1 | public function forPage($page, $perPage = 15) |
|
1010 | |||
1011 | /** |
||
1012 | * Constrain the query to the next "page" of results after a given ID. |
||
1013 | * |
||
1014 | * @param int $perPage |
||
1015 | * @param int $lastId |
||
1016 | * @param string $column |
||
1017 | * @return $this |
||
1018 | */ |
||
1019 | 1 | public function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id') |
|
1025 | |||
1026 | /** |
||
1027 | * Add a union statement to the query. |
||
1028 | * |
||
1029 | * @param \Illuminate\Database\Query\Builder|\Closure $query |
||
1030 | * @param bool $all |
||
1031 | * @return $this |
||
1032 | */ |
||
1033 | 1 | public function union($query, $all = false) |
|
1039 | |||
1040 | /** |
||
1041 | * Add a union all statement to the query. |
||
1042 | * |
||
1043 | * @param \Illuminate\Database\Query\Builder|\Closure $query |
||
1044 | * @return $this |
||
1045 | */ |
||
1046 | 1 | public function unionAll($query) |
|
1052 | |||
1053 | /** |
||
1054 | * Lock the selected rows in the table. |
||
1055 | * |
||
1056 | * @param string|bool $value |
||
1057 | * @return $this |
||
1058 | */ |
||
1059 | 1 | public function lock($value = true) |
|
1065 | |||
1066 | /** |
||
1067 | * Lock the selected rows in the table for updating. |
||
1068 | * |
||
1069 | * @return $this |
||
1070 | */ |
||
1071 | 1 | public function lockForUpdate() |
|
1077 | |||
1078 | /** |
||
1079 | * Share lock the selected rows in the table. |
||
1080 | * |
||
1081 | * @return $this |
||
1082 | */ |
||
1083 | 1 | public function sharedLock() |
|
1089 | |||
1090 | /** |
||
1091 | * Apply the callback's query changes if the given "value" is true. |
||
1092 | * |
||
1093 | * @param mixed $value |
||
1094 | * @param callable $callback |
||
1095 | * @param callable $default |
||
1096 | * @return $this |
||
1097 | */ |
||
1098 | 1 | public function when($value, $callback, $default = null) |
|
1104 | |||
1105 | /** |
||
1106 | * Apply the callback's query changes if the given "value" is false. |
||
1107 | * |
||
1108 | * @param mixed $value |
||
1109 | * @param callable $callback |
||
1110 | * @param callable $default |
||
1111 | * @return $this |
||
1112 | */ |
||
1113 | 1 | public function unless($value, $callback, $default = null) |
|
1119 | |||
1120 | /** |
||
1121 | * Use the write pdo for query. |
||
1122 | * |
||
1123 | * @return $this |
||
1124 | */ |
||
1125 | 2 | public function useWritePdo() |
|
1131 | } |
||
1132 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: