for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace MaxGoryunov\SavingIterator\Fakes;
use Closure;
/**
* Repeats some process several times and returns its result.
* @template X subject type
* @template Y result type
* @implements Repeat<Y>
*/
abstract class RepeatEnvelope implements Repeat
{
* Ctor.
*
* @phpstan-param T $subject
* @phpstan-param Closure(T): Y $context
* @param mixed $subject element to be processed.
* @param Closure $context context for the element.
public function __construct(
* Element to be processed.
* @phpstan-var X
* @var mixed
private mixed $subject,
* Context for the element.
* @phpstan-var Closure(X): Y
* @var Closure
private Closure $context
) {
}
* Returns several results of applying context to subject.
* @param int $count
* @phpstan-return Y[]
* @return mixed[]
public function times(int $count): array
return array_map(
$this->context,
array_fill(0, $count, $this->subject)
);