| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | final class FakeCounter implements CounterInterface |
||
| 9 | { |
||
| 10 | private int $remaining; |
||
| 11 | private int $limit; |
||
| 12 | private int $reset; |
||
| 13 | private string $id; |
||
| 14 | |||
| 15 | public function __construct(int $limit, int $reset) |
||
| 16 | { |
||
| 17 | $this->reset = $reset; |
||
| 18 | $this->limit = $limit; |
||
| 19 | $this->remaining = $limit; |
||
| 20 | } |
||
| 21 | |||
| 22 | public function setId(string $id): void |
||
| 23 | { |
||
| 24 | $this->id = $id; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function getId(): ?string |
||
| 28 | { |
||
| 29 | return $this->id; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function incrementAndGetState(): CounterState |
||
| 33 | { |
||
| 34 | $this->remaining--; |
||
| 35 | return new CounterState($this->limit, $this->remaining, $this->reset); |
||
| 36 | } |
||
| 38 |