Commands::readonly()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Commands recognize
4
 * User: moyo
5
 * Date: 25/10/2017
6
 * Time: 3:12 PM
7
 */
8
9
namespace Carno\Redis\Utils;
10
11
class Commands
12
{
13
    /**
14
     * @var array
15
     */
16
    private const RO_CMDS = [
17
        'info',
18
        'smembers',
19
        'hlen',
20
        'hmget',
21
        'srandmember',
22
        'hvals',
23
        'randomkey',
24
        'strlen',
25
        'dbsize',
26
        'keys',
27
        'ttl',
28
        'lindex',
29
        'type',
30
        'llen',
31
        'dump',
32
        'scard',
33
        'echo',
34
        'lrange',
35
        'zcount',
36
        'exists',
37
        'sdiff',
38
        'zrange',
39
        'mget',
40
        'zrank',
41
        'get',
42
        'getbit',
43
        'getrange',
44
        'zrevrange',
45
        'zrevrangebyscore',
46
        'hexists',
47
        'object',
48
        'sinter',
49
        'zrevrank',
50
        'hget',
51
        'zscore',
52
        'hgetall',
53
        'sismember',
54
    ];
55
56
    /**
57
     * @param string $cmd
58
     * @return bool
59
     */
60
    public static function readonly(string $cmd) : bool
61
    {
62
        return in_array(strtolower($cmd), self::RO_CMDS);
63
    }
64
}
65