Total Complexity | 5 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | class UniqueStrategy implements StrategyInterface |
||
8 | { |
||
9 | /** |
||
10 | * Contains all previously generated values, keyed by the Extension's function name. |
||
11 | * |
||
12 | * @var array<string, array<string, null>> |
||
13 | */ |
||
14 | private array $previous = []; |
||
15 | |||
16 | /** |
||
17 | * With the unique generator you are guaranteed to never get the same two |
||
18 | * values. |
||
19 | * |
||
20 | * <code> |
||
21 | * // will never return twice the same value |
||
22 | * $generator->randomElement(array(1, 2, 3)); |
||
23 | * </code> |
||
24 | * |
||
25 | * @param int $retries Maximum number of retries to find a unique value, |
||
26 | * After which an OverflowException is thrown. |
||
27 | */ |
||
28 | 3 | public function __construct(private readonly int $retries) |
|
30 | 3 | } |
|
31 | |||
32 | 2 | public function generate(string $name, callable $callback): mixed |
|
55 |