refactor: expectation when

This commit is contained in:
Nuno Maduro
2021-09-24 21:10:02 +01:00
parent f23f857903
commit 3c3e6b160b

View File

@ -178,15 +178,16 @@ final class Expectation
}
/**
* It skips the tests in the callback if the condition is not truthy.
* Apply the callback if the given "condition" is truthy.
*
* @param Closure|bool|string $condition
* @param (callable(): bool)|bool $condition
* @param callable(Expectation<TValue>): mixed $callback
*/
public function when($condition, callable $callback): Expectation
{
$condition = is_callable($condition)
? $condition
: function () use ($condition) {
: static function () use ($condition): mixed {
return $condition;
};