Passed
Push — master ( 1c24a5...c12de4 )
by Eugene
03:23
created

RequestTypes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 27
dl 0
loc 39
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

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 PING = 64;
29
30
    private const ALL = [
31
        self::SELECT => 'select',
32
        self::INSERT => 'insert',
33
        self::REPLACE => 'replace',
34
        self::UPDATE => 'update',
35
        self::DELETE => 'delete',
36
        self::AUTHENTICATE => 'authenticate',
37
        self::EVALUATE => 'evaluate',
38
        self::UPSERT => 'upsert',
39
        self::CALL => 'call',
40
        self::EXECUTE => 'execute',
41
        self::PING => 'ping',
42
    ];
43
44
    public static function getName(int $type) : string
45
    {
46
        if (isset(self::ALL[$type])) {
47
            return self::ALL[$type];
48
        }
49
50
        throw new \InvalidArgumentException("Unknown request type #$type.");
51
    }
52
53
    private function __construct()
54
    {
55
    }
56
}
57