TarantoolAdapter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 2
b 0
f 0
dl 0
loc 21
ccs 6
cts 8
cp 0.75
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A call() 0 12 2
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the Tarantool Queue 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\Queue;
15
16
final class TarantoolAdapter
17
{
18
    private $tarantool;
19
20 174
    public function __construct(\Tarantool $tarantool)
21
    {
22 174
        $this->tarantool = $tarantool;
23 174
    }
24
25 166
    public function call(string $funcName, ...$args)
26
    {
27 166
        $result = $this->tarantool->call($funcName, $args);
28
29
        /*
30
         * The $result can be one of the following:
31
         *  1. An array of tuples, [[id, state, data], ...]
32
         *  2. A scalar value, [[value]]
33
         *  3. An empty array, []
34
         */
35
36 146
        return isset($result[0][1]) ? $result : ($result[0] ?? $result);
37
    }
38
}
39