Code Duplication    Length = 17-17 lines in 2 locations

src/ArrayRateLimiter.php 1 location

@@ 27-43 (lines=17) @@
24
        $this->updateCounter($key, $rate->getInterval());
25
    }
26
27
    public function limitSilently(string $identifier, Rate $rate): Status
28
    {
29
        $key = $this->key($identifier, $rate->getInterval());
30
31
        $current = $this->getCurrent($key);
32
33
        if ($current <= $rate->getOperations()) {
34
            $current = $this->updateCounter($key, $rate->getInterval());
35
        }
36
37
        return Status::from(
38
            $identifier,
39
            $current,
40
            $rate->getOperations(),
41
            time() + $this->ttl($key)
42
        );
43
    }
44
45
    private function key(string $identifier, int $interval): string
46
    {

src/RedisRateLimiter.php 1 location

@@ 37-53 (lines=17) @@
34
        $this->updateCounter($key, $rate->getInterval());
35
    }
36
37
    public function limitSilently(string $identifier, Rate $rate): Status
38
    {
39
        $key = $this->key($identifier, $rate->getInterval());
40
41
        $current = $this->getCurrent($key);
42
43
        if ($current <= $rate->getOperations()) {
44
            $current = $this->updateCounter($key, $rate->getInterval());
45
        }
46
47
        return Status::from(
48
            $identifier,
49
            $current,
50
            $rate->getOperations(),
51
            time() + $this->ttl($key)
52
        );
53
    }
54
55
    private function key(string $identifier, int $interval): string
56
    {