Adds tap for Higher Order tests

This commit is contained in:
luke
2021-06-24 22:57:26 +01:00
parent 4f67eff619
commit acef002a2d
5 changed files with 78 additions and 5 deletions

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Pest\Support;
/**
* @internal
*/
final class HigherOrderCallables
{
/**
* @var object
*/
private $target;
public function __construct(object $target)
{
$this->target = $target;
}
/**
* @template TValue
*
* @param callable(): TValue $callable
*
* @return TValue|object
*/
public function tap(callable $callable)
{
return Reflection::bindCallable($callable) ?? $this->target;
}
}