Completed
Pull Request — master (#37)
by Eugene
02:54
created

ExecuteRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getType() 0 4 1
A getBody() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Tarantool Client package.
7
 *
8
 * (c) Eugene Leonovich <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Tarantool\Client\Request;
15
16
use Tarantool\Client\IProto;
17
use Tarantool\Client\RequestTypes;
18
19
final class ExecuteRequest implements Request
20
{
21
    private $sql;
22
    private $params;
23
24 8
    public function __construct(string $sql, array $params = [])
25
    {
26 8
        $this->sql = $sql;
27 8
        $this->params = $params;
28 8
    }
29
30 8
    public function getType() : int
31
    {
32 8
        return RequestTypes::EXECUTE;
33
    }
34
35 8
    public function getBody() : array
36
    {
37 8
        return empty($this->params) ? [
38 6
            IProto::SQL_TEXT => $this->sql,
39
        ] : [
40 2
            IProto::SQL_TEXT => $this->sql,
41 8
            IProto::SQL_BIND => $this->params,
42
        ];
43
    }
44
}
45