@@ -25,6 +25,16 @@ class Builder
2525{
2626 use EscapesValues;
2727
28+ public const TYPE_SEARCH = 'search ' ;
29+
30+ public const TYPE_READ = 'read ' ;
31+
32+ public const TYPE_CHUNK = 'chunk ' ;
33+
34+ public const TYPE_LIST = 'list ' ;
35+
36+ public const TYPE_PAGINATE = 'paginate ' ;
37+
2838 /**
2939 * The base distinguished name placeholder.
3040 */
@@ -77,7 +87,7 @@ class Builder
7787 /**
7888 * The default query type.
7989 */
80- protected string $ type = ' search ' ;
90+ protected string $ type = self :: TYPE_SEARCH ;
8191
8292 /**
8393 * Determine whether the query is nested.
@@ -376,7 +386,7 @@ public function paginate(int $pageSize = 1000, bool $isCritical = false): Collec
376386
377387 $ pages = $ this ->getCachedResponse ($ query , $ callback );
378388
379- $ this ->logQuery ($ this , ' paginate ' , $ this ->getElapsedTime ($ start ));
389+ $ this ->logQuery ($ this , self :: TYPE_PAGINATE , $ this ->getElapsedTime ($ start ));
380390
381391 return $ this ->process ($ pages );
382392 }
@@ -439,7 +449,7 @@ public function chunk(int $pageSize, Closure $callback, bool $isCritical = false
439449 fn (Connection $ replicate ) => $ chunk ($ this ->clone ()->setConnection ($ replicate ))
440450 ) : $ chunk ($ this );
441451
442- $ this ->logQuery ($ this , ' chunk ' , $ this ->getElapsedTime ($ start ));
452+ $ this ->logQuery ($ this , self :: TYPE_CHUNK , $ this ->getElapsedTime ($ start ));
443453
444454 return true ;
445455 }
@@ -1336,7 +1346,7 @@ public function getSelects(): array
13361346 */
13371347 public function read (): static
13381348 {
1339- $ this ->type = ' read ' ;
1349+ $ this ->type = self :: TYPE_READ ;
13401350
13411351 return $ this ;
13421352 }
@@ -1346,17 +1356,25 @@ public function read(): static
13461356 */
13471357 public function list (): static
13481358 {
1349- $ this ->type = ' list ' ;
1359+ $ this ->type = self :: TYPE_LIST ;
13501360
13511361 return $ this ;
13521362 }
13531363
13541364 /**
1355- * Set the query to search the entire directory on the base distinguished name .
1365+ * Alias for the " search" method .
13561366 */
13571367 public function recursive (): static
13581368 {
1359- $ this ->type = 'search ' ;
1369+ return $ this ->search ();
1370+ }
1371+
1372+ /**
1373+ * Set the query to search the entire directory on the base distinguished name.
1374+ */
1375+ public function search (): static
1376+ {
1377+ $ this ->type = self ::TYPE_SEARCH ;
13601378
13611379 return $ this ;
13621380 }
@@ -1621,15 +1639,15 @@ protected function logQuery(Builder $query, string $type, ?float $time = null):
16211639 {
16221640 $ args = [$ query , $ time ];
16231641
1624- $ event = match ( $ type ) {
1625- ' read ' => new Events \ Read (... $ args ),
1626- ' chunk ' => new Events \Chunk (...$ args ),
1627- ' listing ' => new Events \Listing (...$ args ),
1628- ' paginate ' => new Events \Paginate (...$ args ),
1629- default => new Events \Search (...$ args ),
1630- };
1631-
1632- $ this -> fireQueryEvent ( $ event );
1642+ $ this -> fireQueryEvent (
1643+ match ( $ type ) {
1644+ self :: TYPE_READ => new Events \Read (...$ args ),
1645+ self :: TYPE_CHUNK => new Events \Chunk (...$ args ),
1646+ self :: TYPE_LIST => new Events \Listing (...$ args ),
1647+ self :: TYPE_PAGINATE => new Events \Paginate (...$ args ),
1648+ default => new Events \ Search (... $ args ),
1649+ }
1650+ );
16331651 }
16341652
16351653 /**
0 commit comments