Code Duplication    Length = 9-9 lines in 3 locations

src/Storage/RedisCounter.php 3 locations

@@ 28-36 (lines=9) @@
25
        $this->redis = $redis;
26
    }
27
28
    public function increment(string $key): Promise {
29
        return resolve(function () use ($key) {
30
            try {
31
                return yield $this->redis->incr($key);
32
            } catch (RedisException $e) {
33
                throw new StorageFailedException("Failed to increment counter.", 0, $e);
34
            }
35
        });
36
    }
37
38
    public function decrement(string $key): Promise {
39
        return resolve(function () use ($key) {
@@ 38-46 (lines=9) @@
35
        });
36
    }
37
38
    public function decrement(string $key): Promise {
39
        return resolve(function () use ($key) {
40
            try {
41
                return yield $this->redis->eval(self::SCRIPT_DECREMENT, [$key], []);
42
            } catch (RedisException $e) {
43
                throw new StorageFailedException("Failed to decrement counter.", 0, $e);
44
            }
45
        });
46
    }
47
48
    public function get(string $key): Promise {
49
        return resolve(function () use ($key) {
@@ 60-68 (lines=9) @@
57
        });
58
    }
59
60
    public function set(string $key, int $val): Promise {
61
        return resolve(function () use ($key, $val) {
62
            try {
63
                return yield $this->redis->set($key, $val);
64
            } catch (RedisException $e) {
65
                throw new StorageFailedException("Failed to set counter value.", 0, $e);
66
            }
67
        });
68
    }
69
}
70