Completed
Push — master ( bdd4c6...ff5f7b )
by Eugene
03:22
created

TarantoolAdapter::call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 12
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75
rs 10
cc 2
nc 2
nop 2
crap 2.0625
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 170
    public function __construct(\Tarantool $tarantool)
21
    {
22 170
        $this->tarantool = $tarantool;
23 170
    }
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