Skip to content

Commit bb1cc77

Browse files
committed
PHPORM-145 Fix Query\Builder::dump and dd methods to dump MongoDB query
1 parent c694ca4 commit bb1cc77

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/Query/Builder.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use MongoDB\BSON\Regex;
2323
use MongoDB\BSON\UTCDateTime;
2424
use MongoDB\Driver\Cursor;
25+
use Override;
2526
use RuntimeException;
2627

2728
use function array_fill_keys;
@@ -37,6 +38,8 @@
3738
use function call_user_func_array;
3839
use function count;
3940
use function ctype_xdigit;
41+
use function dd;
42+
use function dump;
4043
use function end;
4144
use function explode;
4245
use function func_get_args;
@@ -250,6 +253,30 @@ public function cursor($columns = [])
250253
throw new RuntimeException('Query not compatible with cursor');
251254
}
252255

256+
/**
257+
* Die and dump the current MongoDB query
258+
*
259+
* @return never-return
260+
*/
261+
#[Override]
262+
public function dd()
263+
{
264+
dd($this->toMql());
265+
}
266+
267+
/**
268+
* Dump the current MongoDB query
269+
*
270+
* @return $this
271+
*/
272+
#[Override]
273+
public function dump()
274+
{
275+
dump($this->toMql());
276+
277+
return $this;
278+
}
279+
253280
/**
254281
* Return the MongoDB query to be run in the form of an element array like ['method' => [arguments]].
255282
*

0 commit comments

Comments
 (0)