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

RequestTypes::getName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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