Total Complexity | 6 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | class ChanceStrategy implements StrategyInterface |
||
11 | { |
||
12 | private RandomizerInterface $randomizer; |
||
13 | |||
14 | /** |
||
15 | * Get a value only some percentage of the time. |
||
16 | * |
||
17 | * @param float $weight A probability between 0 and 1, 0 means that we always get the default value. |
||
18 | */ |
||
19 | 2 | public function __construct(private readonly float $weight, ?RandomizerInterface $randomizer = null, private readonly mixed $default = null) |
|
27 | } |
||
28 | } |
||
29 | |||
30 | 1 | public function generate(string $name, callable $callback): mixed |
|
39 |