25 lines
486 B
PHP
25 lines
486 B
PHP
<?php
|
|
|
|
namespace Tests\Fakes;
|
|
|
|
use App\Auth\TokenGenerator;
|
|
|
|
class FakeTokenGenerator implements TokenGenerator
|
|
{
|
|
private int $callCount = 0;
|
|
|
|
/**
|
|
* @param string[] $predefinedTokens
|
|
*/
|
|
public function __construct(
|
|
private array $predefinedTokens,
|
|
) {}
|
|
|
|
public function generate(): string
|
|
{
|
|
$index = $this->callCount % count($this->predefinedTokens);
|
|
$this->callCount++;
|
|
|
|
return $this->predefinedTokens[$index];
|
|
}
|
|
}
|