ExecuteRequest::getBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 2
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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\Request;
15
16
use Tarantool\Client\Keys;
17
use Tarantool\Client\RequestTypes;
18
19
final class ExecuteRequest implements Request
20
{
21
    /** @var non-empty-array<int, int|string|array> */
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-array<int, int|string|array> at position 0 could not be parsed: Unknown type name 'non-empty-array' at position 0 in non-empty-array<int, int|string|array>.
Loading history...
22
    private $body;
23
24
    /**
25
     * @param non-empty-array<int, int|string|array> $body
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-array<int, int|string|array> at position 0 could not be parsed: Unknown type name 'non-empty-array' at position 0 in non-empty-array<int, int|string|array>.
Loading history...
26
     */
27 73
    private function __construct($body)
28
    {
29 73
        $this->body = $body;
30
    }
31
32 65
    public static function fromSql(string $sql, array $params = []) : self
33
    {
34 65
        return new self($params ? [
35 65
            Keys::SQL_TEXT => $sql,
36 65
            Keys::SQL_BIND => $params,
37 65
        ] : [
38 65
            Keys::SQL_TEXT => $sql,
39 65
        ]);
40
    }
41
42 12
    public static function fromStatementId(int $statementId, array $params = []) : self
43
    {
44 12
        return new self($params ? [
45 12
            Keys::STMT_ID => $statementId,
46 12
            Keys::SQL_BIND => $params,
47 12
        ] : [
48 12
            Keys::STMT_ID => $statementId,
49 12
        ]);
50
    }
51
52 73
    public function getType() : int
53
    {
54 73
        return RequestTypes::EXECUTE;
55
    }
56
57 73
    public function getBody() : array
58
    {
59 73
        return $this->body;
60
    }
61
}
62