mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
refactor: expectation when
This commit is contained in:
@ -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
|
public function when($condition, callable $callback): Expectation
|
||||||
{
|
{
|
||||||
$condition = is_callable($condition)
|
$condition = is_callable($condition)
|
||||||
? $condition
|
? $condition
|
||||||
: function () use ($condition) {
|
: static function () use ($condition): mixed {
|
||||||
return $condition;
|
return $condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user