Merge pull request #860 from devajmeireles/feature/add-dd-conditionally

Feature: Introducing The Ability to Dump Conditionally
This commit is contained in:
Nuno Maduro
2023-08-09 10:50:53 +00:00
committed by GitHub

View File

@ -127,6 +127,32 @@ final class Expectation
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;
}
$this->dd($this->value, ...$arguments);
}
/**
* Dump the expectation value when the result of the condition is falsy.
*
* @param bool $boolean
* @return never
*/
public function ddUnless($boolean, mixed ...$arguments): void
{
$this->ddWhen(! $boolean, ...$arguments);
}
/**
* Send the expectation value to Ray along with all given arguments.
*