Sql   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 43
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setMode() 0 3 1
A getMode() 0 3 1
A getPath() 0 3 1
A getMethod() 0 3 1
A getBody() 0 10 3
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