Lines
66.66%
2 / 3
Methods
66.66%
2 / 3
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| forRepeatedWarnings | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| includesOccurrence | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 3 | ||
| 7 | final readonly class EveryNthOccurrence | |
| 8 | { | |
| 9 | private const int REPEATED_WARNING_INTERVAL = 100; | |
| 10 | ||
| 11 | public function __construct(private int $every) {} | |
| 12 | ||
| 13 | public static function forRepeatedWarnings(): self | |
| 14 | { | |
| 15 | return new self(self::REPEATED_WARNING_INTERVAL); | |
| 16 | } | |
| 17 | ||
| 18 | public function includesOccurrence(int $occurrence): bool | |
| 19 | { | |
| 20 | return $occurrence === 1 || ($occurrence > 0 && $occurrence % $this->every === 0); | |
| 21 | } | |
| 22 | } |