Skip to content

Commit

Permalink
Feature: Introducing The Ability to Dump Conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
devajmeireles committed Jul 17, 2023
1 parent 23d7191 commit ea967b4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,48 @@ public function dd(mixed ...$arguments): void
exit(1);
}

/**
* Dump the expectation value when the result of the condition is truthy.
*
* @param bool $boolean
* @return never
*/
public function ddWhen($boolean, mixed ...$arguments): void
{
if (! $boolean) {
return;
}

if (function_exists('dd')) {
dd($this->value, ...$arguments);
}

var_dump($this->value);

exit(1);
}

/**
* Dump the expectation value when the result of the condition is falsy.
*
* @param bool $boolean
* @return never
*/
public function ddUnless($boolean, mixed ...$arguments): void
{
if ($boolean) {
return;
}

if (function_exists('dd')) {
dd($this->value, ...$arguments);
}

var_dump($this->value);

exit(1);
}

/**
* Send the expectation value to Ray along with all given arguments.
*
Expand Down

0 comments on commit ea967b4

Please sign in to comment.