Connection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 82
ccs 12
cts 12
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hincrbyfloat() 0 3 1
A lrange() 0 3 1
A flushdb() 0 3 1
A rpush() 0 3 1
A hgetall() 0 3 1
A hset() 0 3 1
1
<?php
2
3
namespace Krenor\Prometheus\Storage\Redis;
4
5
abstract class Connection
6
{
7
    /**
8
     * @var \Predis\Client
9
     */
10
    protected $client;
11
12
    /**
13
     * @see https://redis.io/commands/hgetall
14
     *
15
     * @param string $key
16
     *
17
     * @return array
18
     */
19 12
    public function hgetall(string $key): array
20
    {
21 12
        return $this->client->hgetall($key);
22
    }
23
24
    /**
25
     * @see https://redis.io/commands/lrange
26
     *
27
     * @param string $key
28
     * @param int $start
29
     * @param int $stop
30
     *
31
     * @return array
32
     */
33 2
    public function lrange(string $key, int $start, int $stop): array
34
    {
35 2
        return $this->client->lrange($key, $start, $stop);
36
    }
37
38
    /**
39
     * @see https://redis.io/commands/hincrbyfloat
40
     *
41
     * @param string $key
42
     * @param string $field
43
     * @param float $value
44
     *
45
     * @return float
46
     */
47 8
    public function hincrbyfloat(string $key, string $field, float $value): float
48
    {
49 8
        return $this->client->hincrbyfloat($key, $field, $value);
50
    }
51
52
    /**
53
     * @see https://redis.io/commands/hset
54
     *
55
     * @param string $key
56
     * @param string $field
57
     * @param mixed $value
58
     *
59
     * @return int
60
     */
61 2
    public function hset(string $key, string $field, mixed $value): int
62
    {
63 2
        return $this->client->hset($key, $field, $value);
64
    }
65
66
    /**
67
     * @see https://redis.io/commands/rpush
68
     *
69
     * @param string $key
70
     * @param array $values
71
     *
72
     * @return int
73
     */
74 2
    public function rpush(string $key, array $values): int
75
    {
76 2
        return $this->client->rpush($key, ...$values);
77
    }
78
79
    /**
80
     * @see https://redis.io/commands/flushdb
81
     *
82
     * @return bool
83
     */
84 6
    public function flushdb(): bool
85
    {
86 6
        return $this->client->flushdb();
87
    }
88
}
89