RequestTypes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
eloc 29
c 3
b 0
f 2
dl 0
loc 41
rs 10
ccs 0
cts 5
cp 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 7 2
A __construct() 0 2 1
1
<?php
2
3
/**
4
 * This file is part of the tarantool/client package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Tarantool\Client;
15
16
final class RequestTypes
17
{
18
    public const SELECT = 1;
19
    public const INSERT = 2;
20
    public const REPLACE = 3;
21
    public const UPDATE = 4;
22
    public const DELETE = 5;
23
    public const AUTHENTICATE = 7;
24
    public const EVALUATE = 8;
25
    public const UPSERT = 9;
26
    public const CALL = 10;
27
    public const EXECUTE = 11;
28
    public const PREPARE = 13;
29
    public const PING = 64;
30
31
    private const ALL = [
32
        self::SELECT => 'select',
33
        self::INSERT => 'insert',
34
        self::REPLACE => 'replace',
35
        self::UPDATE => 'update',
36
        self::DELETE => 'delete',
37
        self::AUTHENTICATE => 'authenticate',
38
        self::EVALUATE => 'evaluate',
39
        self::UPSERT => 'upsert',
40
        self::CALL => 'call',
41
        self::EXECUTE => 'execute',
42
        self::PREPARE => 'prepare',
43
        self::PING => 'ping',
44
    ];
45
46
    public static function getName(int $type) : string
47
    {
48
        if (isset(self::ALL[$type])) {
49
            return self::ALL[$type];
50
        }
51
52
        throw new \InvalidArgumentException("Unknown request type #$type");
53
    }
54
55
    private function __construct()
56
    {
57
    }
58
}
59