Sql::getMode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace Manticoresearch\Endpoints;
5
6
use Manticoresearch\Request;
7
8
/**
9
 * Class Sql
10
 * @package Manticoresearch\Endpoints
11
 */
12
class Sql extends Request
13
{
14
    /**
15
     * @return mixed|string
16
     */
17
    protected $mode;
18
    public function getPath()
19
    {
20
        return '/sql';
21
    }
22
23
    /**
24
     * @return mixed|string
25
     */
26
    public function getMethod()
27
    {
28
        return 'POST';
29
    }
30
31
    /**
32
     * @return mixed|string
33
     */
34
    public function getBody()
35
    {
36
        if ($this->mode === 'raw') {
37
            $return = ['mode=raw'];
38
            foreach ($this->body as $k => $v) {
39
                $return[]= $k.'='.urlencode($v);
40
            }
41
            return implode('&', $return);
42
        } else {
43
            return http_build_query($this->body);
0 ignored issues
show
Bug introduced by
It seems like $this->body can also be of type string; however, parameter $data of http_build_query() does only seem to accept array|object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
            return http_build_query(/** @scrutinizer ignore-type */ $this->body);
Loading history...
44
        }
45
    }
46
47
    public function getMode()
48
    {
49
        return $this->mode;
50
    }
51
52
    public function setMode($mode)
53
    {
54
        $this->mode = $mode;
55
    }
56
}
57